Predefined Constants

INTL_ICU_VERSION (string)
The current ICU library version as a dotted-decimal string.
INTL_MAX_LOCALE_LEN (integer)
Limit on locale length, set to 80 in PHP code. Locale names longer than this limit will not be accepted.
IDNA_DEFAULT (integer)
Prohibit processing of unassigned codepoints in the input for IDN functions and do not check if the input conforms to domain name ASCII rules.
IDNA_ALLOW_UNASSIGNED (integer)
Allow processing of unassigned codepoints in the input for IDN functions.
IDNA_USE_STD3_RULES (integer)
Check if the input for IDN functions conforms to domain name ASCII rules.
IDNA_CHECK_BIDI (integer)
Check whether the input conforms to the BiDi rules. Ignored by the IDNA2003 implementation, which always performs this check.
IDNA_CHECK_CONTEXTJ (integer)
Check whether the input conforms to the CONTEXTJ rules. Ignored by the IDNA2003 implementation, as this check is new in IDNA2008.
IDNA_NONTRANSITIONAL_TO_ASCII (integer)
Option for nontransitional processing in idn_to_ascii(). Transitional processing is activated by default. This option is ignored by the IDNA2003 implementation.
IDNA_NONTRANSITIONAL_TO_UNICODE (integer)
Option for nontransitional processing in idn_to_utf8(). Transitional processing is activated by default. This option is ignored by the IDNA2003 implementation.
INTL_IDNA_VARIANT_2003 (integer)
Use IDNA 2003 algorithm in idn_to_utf8() and idn_to_ascii(). This is the default. This constant and using the default has been deprecated as of PHP 7.2.0.
INTL_IDNA_VARIANT_UTS46 (integer)
Use UTS #46 algorithm in idn_to_utf8() and idn_to_ascii(). Available as of ICU 4.6.
IDNA_ERROR_EMPTY_LABEL (integer)
IDNA_ERROR_LABEL_TOO_LONG (integer)
IDNA_ERROR_DOMAIN_NAME_TOO_LONG (integer)
IDNA_ERROR_LEADING_HYPHEN (integer)
IDNA_ERROR_TRAILING_HYPHEN (integer)
IDNA_ERROR_HYPHEN_3_4 (integer)
IDNA_ERROR_LEADING_COMBINING_MARK (integer)
IDNA_ERROR_DISALLOWED (integer)
IDNA_ERROR_PUNYCODE (integer)
IDNA_ERROR_LABEL_HAS_DOT (integer)
IDNA_ERROR_INVALID_ACE_LABEL (integer)
IDNA_ERROR_BIDI (integer)
IDNA_ERROR_CONTEXTJ (integer)
Errors reported in a bitset returned by the UTS #46 algorithm in idn_to_utf8() and idn_to_ascii().



Examples

Table of Contents


Basic usage of this extension

Each module provides two kind of APIs: a procedural one and an object oriented one. Both are actually identical and described in the corresponding document.

Note:

All input strings must be in UTF-8 encoding. All output strings are also in UTF-8.

Example #1 Example of using the procedural API

<?php
$coll  
collator_create('en_US');
$result collator_compare($coll"string#1""string#2");
?>

Example #2 Example of using the object-oriented API

<?php
$coll 
= new Collator('en_US');
$al   $coll->getLocale(Locale::ACTUAL_LOCALE);
echo 
"Actual locale: $al\n";

$formatter = new NumberFormatter('en_US'NumberFormatter::DECIMAL);
echo 
$formatter->format(1234567);
?>



The Collator class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

Provides string comparison capability with support for appropriate locale-sensitive sort orderings.

Class synopsis

Collator {
/* Methods */
public __construct ( string $locale )
public asort ( array &$arr [, int $sort_flag ] ) : bool
public compare ( string $str1 , string $str2 ) : int
public static create ( string $locale ) : Collator
public getAttribute ( int $attr ) : int
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getLocale ( int $type ) : string
public getSortKey ( string $str ) : string
public getStrength ( void ) : int
public setAttribute ( int $attr , int $val ) : bool
public setStrength ( int $strength ) : bool
public sortWithSortKeys ( array &$arr ) : bool
public sort ( array &$arr [, int $sort_flag ] ) : bool
}

Predefined Constants

Collator::FRENCH_COLLATION (integer)

Sort strings with different accents from the back of the string. This attribute is automatically set to On for the French locales and a few others. Users normally would not need to explicitly set this attribute. There is a string comparison performance cost when it is set On, but sort key length is unaffected. Possible values are:

  • Collator::ON
  • Collator::OFF(default)
  • Collator::DEFAULT_VALUE

Example #1 FRENCH_COLLATION rules

  • F=OFF cote < coté < côte < côté
  • F=ON cote < côte < coté < côté

Collator::ALTERNATE_HANDLING (integer)

The Alternate attribute is used to control the handling of the so called variable characters in the UCA: whitespace, punctuation and symbols. If Alternate is set to NonIgnorable (N), then differences among these characters are of the same importance as differences among letters. If Alternate is set to Shifted (S), then these characters are of only minor importance. The Shifted value is often used in combination with Strength set to Quaternary. In such a case, whitespace, punctuation, and symbols are considered when comparing strings, but only if all other aspects of the strings (base letters, accents, and case) are identical. If Alternate is not set to Shifted, then there is no difference between a Strength of 3 and a Strength of 4. For more information and examples, see Variable_Weighting in the » UCA. The reason the Alternate values are not simply On and Off is that additional Alternate values may be added in the future. The UCA option Blanked is expressed with Strength set to 3, and Alternate set to Shifted. The default for most locales is NonIgnorable. If Shifted is selected, it may be slower if there are many strings that are the same except for punctuation; sort key length will not be affected unless the strength level is also increased.

Possible values are:

  • Collator::NON_IGNORABLE(default)
  • Collator::SHIFTED
  • Collator::DEFAULT_VALUE

Example #2 ALTERNATE_HANDLING rules

  • S=3, A=N di Silva < Di Silva < diSilva < U.S.A. < USA
  • S=3, A=S di Silva = diSilva < Di Silva < U.S.A. = USA
  • S=4, A=S di Silva < diSilva < Di Silva < U.S.A. < USA

Collator::CASE_FIRST (integer)

The Case_First attribute is used to control whether uppercase letters come before lowercase letters or vice versa, in the absence of other differences in the strings. The possible values are Uppercase_First (U) and Lowercase_First (L), plus the standard Default and Off. There is almost no difference between the Off and Lowercase_First options in terms of results, so typically users will not use Lowercase_First: only Off or Uppercase_First. (People interested in the detailed differences between X and L should consult the Collation Customization). Specifying either L or U won't affect string comparison performance, but will affect the sort key length.

Possible values are:

  • Collator::OFF(default)
  • Collator::LOWER_FIRST
  • Collator::UPPER_FIRST
  • Collator:DEFAULT

Example #3 CASE_FIRST rules

  • C=X or C=L "china" < "China" < "denmark" < "Denmark"
  • C=U "China" < "china" < "Denmark" < "denmark"

Collator::CASE_LEVEL (integer)

The Case_Level attribute is used when ignoring accents but not case. In such a situation, set Strength to be Primary, and Case_Level to be On. In most locales, this setting is Off by default. There is a small string comparison performance and sort key impact if this attribute is set to be On.

Possible values are:

  • Collator::OFF(default)
  • Collator::ON
  • Collator::DEFAULT_VALUE

Example #4 CASE_LEVEL rules

  • S=1, E=X role = Role = rôle
  • S=1, E=O role = rôle < Role

Collator::NORMALIZATION_MODE (integer)

The Normalization setting determines whether text is thoroughly normalized or not in comparison. Even if the setting is off (which is the default for many locales), text as represented in common usage will compare correctly (for details, see UTN #5). Only if the accent marks are in noncanonical order will there be a problem. If the setting is On, then the best results are guaranteed for all possible text input. There is a medium string comparison performance cost if this attribute is On, depending on the frequency of sequences that require normalization. There is no significant effect on sort key length. If the input text is known to be in NFD or NFKD normalization forms, there is no need to enable this Normalization option.

Possible values are:

  • Collator::OFF(default)
  • Collator::ON
  • Collator::DEFAULT_VALUE

Collator::STRENGTH (integer)

The ICU Collation Service supports many levels of comparison (named "Levels", but also known as "Strengths"). Having these categories enables ICU to sort strings precisely according to local conventions. However, by allowing the levels to be selectively employed, searching for a string in text can be performed with various matching conditions. For more detailed information, see collator_set_strength() chapter.

Possible values are:

  • Collator::PRIMARY
  • Collator::SECONDARY
  • Collator::TERTIARY(default)
  • Collator::QUATERNARY
  • Collator::IDENTICAL
  • Collator::DEFAULT_VALUE

Collator::HIRAGANA_QUATERNARY_MODE (integer)

Compatibility with JIS x 4061 requires the introduction of an additional level to distinguish Hiragana and Katakana characters. If compatibility with that standard is required, then this attribute should be set On, and the strength set to Quaternary. This will affect sort key length and string comparison string comparison performance.

Possible values are:

  • Collator::OFF(default)
  • Collator::ON
  • Collator::DEFAULT_VALUE

Collator::NUMERIC_COLLATION (integer)

When turned on, this attribute generates a collation key for the numeric value of substrings of digits. This is a way to get '100' to sort AFTER '2'.

Possible values are:

  • Collator::OFF(default)
  • Collator::ON
  • Collator::DEFAULT_VALUE

Collator::DEFAULT_VALUE (integer)
Collator::PRIMARY (integer)
Collator::SECONDARY (integer)
Collator::TERTIARY (integer)
Collator::DEFAULT_STRENGTH (integer)
Collator::QUATERNARY (integer)
Collator::IDENTICAL (integer)
Collator::OFF (integer)
Collator::ON (integer)
Collator::SHIFTED (integer)
Collator::NON_IGNORABLE (integer)
Collator::LOWER_FIRST (integer)
Collator::UPPER_FIRST (integer)


Collator::asort

collator_asort

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::asort -- collator_asortSort array maintaining index association

Description

Object oriented style

public Collator::asort ( array &$arr [, int $sort_flag ] ) : bool

Procedural style

collator_asort ( Collator $coll , array &$arr [, int $sort_flag ] ) : bool

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Array elements will have sort order according to current locale rules.

Equivalent to standard PHP asort().

Parameters

coll

Collator object.

arr

Array of strings to sort.

sort_flag

Optional sorting type, one of the following:

  • Collator::SORT_REGULAR - compare items normally (don't change types)

  • Collator::SORT_NUMERIC - compare items numerically

  • Collator::SORT_STRING - compare items as strings

Default $sort_flag value is Collator::SORT_REGULAR. It is also used if an invalid $sort_flag value has been specified.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 collator_asort()example

<?php
$coll 
collator_create'en_US' );
$arr = array(
     
'a' => '100',
     
'b' => '50',
     
'c' => '7'
);
collator_asort$coll$arrCollator::SORT_NUMERIC );
var_export$arr );

collator_asort$coll$arrCollator::SORT_STRING );
var_export$arr );
?>

The above example will output:

   array (
     'c' => '7',
     'b' => '50',
     'a' => '100',
   )array (
     'a' => '100',
     'b' => '50',
     'c' => '7',
   )
   

See Also



Collator::compare

collator_compare

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::compare -- collator_compareCompare two Unicode strings

Description

Object oriented style

public Collator::compare ( string $str1 , string $str2 ) : int

Procedural style

collator_compare ( Collator $coll , string $str1 , string $str2 ) : int

Compare two Unicode strings according to collation rules.

Parameters

coll

Collator object.

str1

The first string to compare.

str2

The second string to compare.

Return Values

Return comparison result:

  • 1 if str1 is greater than str2 ;

  • 0 if str1 is equal to str2;

  • -1 if str1 is less than str2 .

On error boolean FALSE is returned.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Examples

Example #1 collator_compare()example

<?php
$s1 
'Hello';
$s2 'hello';

$coll collator_create'en_US' );
$res  collator_compare$coll$s1$s2 );

if (
$res === false) {
    echo 
collator_get_error_message$coll );
} else if( 
$res ) {
    echo 
"s1 is greater than s2\n";
} else if( 
$res ) {
    echo 
"s1 is less than s2\n";
} else {
    echo 
"s1 is equal to s2\n";
}
?>

The above example will output:


s1 is greater than s2

See Also



Collator::__construct

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::__constructCreate a collator

Description

public Collator::__construct ( string $locale )

Creates a new instance of Collator.

Parameters

locale

The locale whose collation rules should be used. Special values for locales can be passed in - if null is passed for the locale, the default locale's collation rules will be used. If "root" is passed, UCA rules will be used.

The Locale attribute is typically the most important attribute for correct sorting and matching, according to the user expectations in different countries and regions. The default » UCA ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" meaning according to the normal expectations for users of the languages). Otherwise, you need to supply the locale to UCA in order to properly collate text for a given language. Thus a locale needs to be supplied so as to choose a collator that is correctly tailored for that locale. The choice of a locale will automatically preset the values for all of the attributes to something that is reasonable for that locale. Thus most of the time the other attributes do not need to be explicitly set. In some cases, the choice of locale will make a difference in string comparison performance and/or sort key length.

Return Values

Returns Collator instance.

Errors/Exceptions

Returns an "empty" object on error. You can use intl_get_error_code() and/or intl_get_error_message() to know what happened.

Examples

Example #1 Collator::__construct() example

<?php
$coll 
= new Collator'en_CA' );
?>

See Also



Collator::create

collator_create

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::create -- collator_createCreate a collator

Description

Object oriented style

public static Collator::create ( string $locale ) : Collator

Procedural style

collator_create ( string $locale ) : Collator

The strings will be compared using the options already specified.

Parameters

locale

The locale containing the required collation rules. Special values for locales can be passed in - if null is passed for the locale, the default locale collation rules will be used. If empty string ("") or "root" are passed, » UCA rules will be used.

Return Values

Return new instance of Collator object, or NULL on error.

Examples

Example #1 collator_create() example

<?php
$coll 
collator_create'en_US' );

if( !isset( 
$coll ) ) {
    
printf"Collator creation failed: %s\n"intl_get_error_message() );
    exit( 
);
}
?>

See Also



Collator::getAttribute

collator_get_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::getAttribute -- collator_get_attributeGet collation attribute value

Description

Object oriented style

public Collator::getAttribute ( int $attr ) : int

Procedural style

collator_get_attribute ( Collator $coll , int $attr ) : int

Get a value of an integer collator attribute.

Parameters

coll

Collator object.

attr

Attribute to get value for.

Return Values

Attribute value, or boolean FALSE on error.

Examples

Example #1 collator_get_attribute() example

<?php
$coll 
collator_create'en_CA' );
$val collator_get_attribute$collCollator::NUMERIC_COLLATION );
if( 
$val === false )
{
    
// Handle error.
}
?>

See Also



Collator::getErrorCode

collator_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::getErrorCode -- collator_get_error_codeGet collator's last error code

Description

Object oriented style

public Collator::getErrorCode ( void ) : int

Procedural style

collator_get_error_code ( Collator $coll ) : int

Parameters

coll

Collator object.

Return Values

Error code returned by the last Collator API function call.

Examples

Example #1 collator_get_error_code() example

<?php
$coll 
collator_create'en_US' );
if( 
collator_get_attribute$collCollator::FRENCH_COLLATION ) === false )
        
handle_errorcollator_get_error_code() );
?>

See Also



Collator::getErrorMessage

collator_get_error_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::getErrorMessage -- collator_get_error_messageGet text for collator's last error code

Description

Object oriented style

public Collator::getErrorMessage ( void ) : string

Procedural style

collator_get_error_message ( Collator $coll ) : string

Retrieves the message for the last error.

Parameters

coll

Collator object.

Return Values

Description of an error occurred in the last Collator API function call.

Examples

Example #1 collator_get_error_message() example

<?php
$coll 
collator_create'lt' );
if( 
collator_compare$coll'y''k' ) === false ) {
    echo 
collator_get_error_message$coll );
}
?>

See Also



Collator::getLocale

collator_get_locale

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::getLocale -- collator_get_localeGet the locale name of the collator

Description

Object oriented style

public Collator::getLocale ( int $type ) : string

Procedural style

collator_get_locale ( Collator $coll , int $type ) : string

Get collector locale name.

Parameters

coll

Collator object.

type

You can choose between valid and actual locale ( Locale::VALID_LOCALE and Locale::ACTUAL_LOCALE, respectively).

Return Values

Real locale name from which the collation data comes. If the collator was instantiated from rules or an error occurred, returns boolean FALSE.

Examples

Example #1 collator_get_locale() example

<?php
$coll    
collator_create'en_US_California' );
$res_val collator_get_locale$collLocale::VALID_LOCALE );
$res_act collator_get_locale$collLocale::ACTUAL_LOCALE );
printf"Valid locale name: %s\nActual locale name: %s\n",
         
$res_val$res_act );
?>

The above example will output:

   Requested locale name: en_US_California
   Valid locale name: en_US
   Actual locale name: en
   

See Also



Collator::getSortKey

collator_get_sort_key

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 1.0.3)

Collator::getSortKey -- collator_get_sort_keyGet sorting key for a string

Description

Object oriented style

public Collator::getSortKey ( string $str ) : string

Procedural style

collator_get_sort_key ( Collator $coll , string $str ) : string

Return collation key for a string. Collation keys can be compared directly instead of strings, though are implementation specific and may change between ICU library versions. Sort keys are generally only useful in databases or other circumstances where function calls are extremely expensive.

Parameters

coll

Collator object.

str

The string to produce the key from.

Return Values

Returns the collation key for the string, or FALSE on failure.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Changelog

Version Description
5.3.15, 5.4.5 Sort keys do no longer contain any NUL bytes.

Examples

Example #1 collator_get_sort_key()example

<?php
$s1 
'Hello';

$coll collator_create('en_US');
$res  collator_get_sort_key($coll$s1);

echo 
bin2hex($res);
?>

The above example will output something similar to:


3832404046010901dc08

See Also



Collator::getStrength

collator_get_strength

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::getStrength -- collator_get_strengthGet current collation strength

Description

Object oriented style

public Collator::getStrength ( void ) : int

Procedural style

collator_get_strength ( Collator $coll ) : int

Parameters

coll

Collator object.

Return Values

Returns current collation strength, or boolean FALSE on error.

Examples

Example #1 collator_get_strength() example

<?php
$coll     
collator_create'en_US' );
$strength collator_get_strength$coll );
?>

See Also



Collator::setAttribute

collator_set_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::setAttribute -- collator_set_attributeSet collation attribute

Description

Object oriented style

public Collator::setAttribute ( int $attr , int $val ) : bool

Procedural style

collator_set_attribute ( Collator $coll , int $attr , int $val ) : bool

Parameters

coll

Collator object.

attr

Attribute.

val

Attribute value.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 collator_set_attribute() example

<?php
$coll 
collator_create'en_CA' );
$val  collator_get_attribute$collCollator::NUMERIC_COLLATION );
if (
$val === false) {
    
// Handle error.
} elseif ($val === Collator::ON) {
    
// Do something useful.
}
?>

See Also



Collator::setStrength

collator_set_strength

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::setStrength -- collator_set_strengthSet collation strength

Description

Object oriented style

public Collator::setStrength ( int $strength ) : bool

Procedural style

collator_set_strength ( Collator $coll , int $strength ) : bool

The » ICU Collation Service supports many levels of comparison (named "Levels", but also known as "Strengths"). Having these categories enables ICU to sort strings precisely according to local conventions. However, by allowing the levels to be selectively employed, searching for a string in text can be performed with various matching conditions.

  1. Primary Level: Typically, this is used to denote differences between base characters (for example, "a" < "b"). It is the strongest difference. For example, dictionaries are divided into different sections by base character. This is also called the level1 strength.

  2. Secondary Level: Accents in the characters are considered secondary differences (for example, "as" < "às" < "at"). Other differences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings. This is also called the level2 strength.

    Note:

    Note: In some languages (such as Danish), certain accented letters are considered to be separate base characters. In most languages, however, an accented letter only has a secondary difference from the unaccented version of that letter.

  3. Tertiary Level: Upper and lower case differences in characters are distinguished at the tertiary level (for example, "ao" < "Ao" < "aò"). In addition, a variant of a letter differs from the base form on the tertiary level (such as "A" and " "). Another example is the difference between large and small Kana. A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings. This is also called the level3 strength.

  4. Quaternary Level: When punctuation is ignored (see Ignoring Punctuations ) at level 13, an additional level can be used to distinguish words with and without punctuation (for example, "ab" < "a-b" < "aB"). This difference is ignored when there is a primary, secondary or tertiary difference. This is also known as the level4 strength. The quaternary level should only be used if ignoring punctuation is required or when processing Japanese text (see Hiragana processing).

  5. Identical Level: When all other levels are equal, the identical level is used as a tiebreaker. The Unicode code point values of the NFD form of each string are compared at this level, just in case there is no difference at levels 14. For example, Hebrew cantillation marks are only distinguished at this level. This level should be used sparingly, as only code point values differences between two strings is an extremely rare occurrence. Using this level substantially decreases the performance for both incremental comparison and sort key generation (as well as increasing the sort key length). It is also known as level 5 strength.

For example, people may choose to ignore accents or ignore accents and case when searching for text. Almost all characters are distinguished by the first three levels, and in most locales the default value is thus Tertiary. However, if Alternate is set to be Shifted, then the Quaternary strength can be used to break ties among whitespace, punctuation, and symbols that would otherwise be ignored. If very fine distinctions among characters are required, then the Identical strength can be used (for example, Identical Strength distinguishes between the Mathematical Bold Small A and the Mathematical Italic Small A.). However, using levels higher than Tertiary the Identical strength result in significantly longer sort keys, and slower string comparison performance for equal strings.

Parameters

coll

Collator object.

strength

Strength to set.

Possible values are:

  • Collator::PRIMARY

  • Collator::SECONDARY

  • Collator::TERTIARY

  • Collator::QUATERNARY

  • Collator::IDENTICAL

  • Collator::DEFAULT_STRENGTH

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 collator_set_strength() example

<?php
$arr  
= array( 'aò''Ao''ao' );
$coll collator_create'en_US' );

// Sort array using default strength.
collator_sort$coll$arr ); 
var_export$arr );

// Sort array using primary strength.
collator_set_strength$collCollator::PRIMARY );
collator_sort$coll$arr );
var_export$arr );
?>

The above example will output:

   array (
     0 => 'ao',
     1 => 'Ao',
     2 => 'aò',
   )
   array (
     0 => 'aò',
     1 => 'Ao',
     2 => 'ao',
   )
   

See Also



Collator::sortWithSortKeys

collator_sort_with_sort_keys

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::sortWithSortKeys -- collator_sort_with_sort_keysSort array using specified collator and sort keys

Description

Object oriented style

public Collator::sortWithSortKeys ( array &$arr ) : bool

Procedural style

collator_sort_with_sort_keys ( Collator $coll , array &$arr ) : bool

Similar to collator_sort() but uses ICU sorting keys produced by ucol_getSortKey() to gain more speed on large arrays.

Parameters

coll

Collator object.

arr

Array of strings to sort

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 collator_sort_with_sort_keys() example

<?php
$arr  
= array( 'Köpfe''Kypper''Kopfe' );
$coll collator_create'sv' );

collator_sort_with_sort_keys$coll$arr );
var_export$arr );
?>

The above example will output:

   array (
     0 => 'Kopfe',
     1 => 'Kypper',
     2 => 'Köpfe',
   )
   

See Also



Collator::sort

collator_sort

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Collator::sort -- collator_sortSort array using specified collator

Description

Object oriented style

public Collator::sort ( array &$arr [, int $sort_flag ] ) : bool

Procedural style

collator_sort ( Collator $coll , array &$arr [, int $sort_flag ] ) : bool

This function sorts an array according to current locale rules.

Equivalent to standard PHP sort() .

Parameters

coll

Collator object.

arr

Array of strings to sort.

sort_flag

Optional sorting type, one of the following:

  • Collator::SORT_REGULAR - compare items normally (don't change types)

  • Collator::SORT_NUMERIC - compare items numerically

  • Collator::SORT_STRING - compare items as strings

Default sorting type is Collator::SORT_REGULAR. It is also used if an invalid sort_flag value has been specified.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 collator_sort() example

<?php
$coll 
collator_create'en_US' );
$arr  = array( 'at''às''as' );

var_export$arr );
collator_sort$coll$arr );
var_export$arr );
?>

The above example will output:

   array (
     0 => 'at',
     1 => 'às',
     2 => 'as',
   )array (
     0 => 'as',
     1 => 'às',
     2 => 'at',
   )
   

See Also


Table of Contents



The NumberFormatter class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

Programs store and operate on numbers using a locale-independent binary representation. When displaying or printing a number it is converted to a locale-specific string. For example, the number 12345.67 is "12,345.67" in the US, "12 345,67" in France and "12.345,67" in Germany.

By invoking the methods provided by the NumberFormatter class, you can format numbers, currencies, and percentages according to the specified or default locale. NumberFormatter is locale-sensitive so you need to create a new NumberFormatter for each locale. NumberFormatter methods format primitive-type numbers, such as double and output the number as a locale-specific string.

For currencies you can use currency format type to create a formatter that returns a string with the formatted number and the appropriate currency sign. Of course, the NumberFormatter class is unaware of exchange rates so, the number output is the same regardless of the specified currency. This means that the same number has different monetary values depending on the currency locale. If the number is 9988776.65 the results will be:

  • 9 988 776,65 € in France
  • 9.988.776,65 € in Germany
  • $9,988,776.65 in the United States

In order to format percentages, create a locale-specific formatter with percentage format type. With this formatter, a decimal fraction such as 0.75 is displayed as 75%.

For more complex formatting, like spelled-out numbers, the rule-based number formatters are used.

Class synopsis

NumberFormatter {
/* Methods */
public __construct ( string $locale , int $style [, string $pattern ] )
public static create ( string $locale , int $style [, string $pattern ] ) : NumberFormatter
public formatCurrency ( float $value , string $currency ) : string
public format ( number $value [, int $type ] ) : string
public getAttribute ( int $attr ) : int
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getLocale ([ int $type ] ) : string
public getPattern ( void ) : string
public getSymbol ( int $attr ) : string
public getTextAttribute ( int $attr ) : string
public parseCurrency ( string $value , string &$currency [, int &$position ] ) : float
public parse ( string $value [, int $type [, int &$position ]] ) : mixed
public setAttribute ( int $attr , int $value ) : bool
public setPattern ( string $pattern ) : bool
public setSymbol ( int $attr , string $value ) : bool
public setTextAttribute ( int $attr , string $value ) : bool
}

Predefined Constants

These styles are used by the numfmt_create() to define the type of the formatter.

NumberFormatter::PATTERN_DECIMAL (integer)
Decimal format defined by pattern
NumberFormatter::DECIMAL (integer)
Decimal format
NumberFormatter::CURRENCY (integer)
Currency format
NumberFormatter::PERCENT (integer)
Percent format
NumberFormatter::SCIENTIFIC (integer)
Scientific format
NumberFormatter::SPELLOUT (integer)
Spellout rule-based format
NumberFormatter::ORDINAL (integer)
Ordinal rule-based format
NumberFormatter::DURATION (integer)
Duration rule-based format
NumberFormatter::PATTERN_RULEBASED (integer)
Rule-based format defined by pattern
NumberFormatter::CURRENCY_ACCOUNTING (integer)
Currency format for accounting, e.g., ($3.00) for negative currency amount instead of -$3.00. Available as of PHP 7.4.1 and ICU 53.
NumberFormatter::DEFAULT_STYLE (integer)
Default format for the locale
NumberFormatter::IGNORE (integer)
Alias for PATTERN_DECIMAL

These constants define how the numbers are parsed or formatted. They should be used as arguments to numfmt_format() and numfmt_parse().

NumberFormatter::TYPE_DEFAULT (integer)
Derive the type from variable type
NumberFormatter::TYPE_INT32 (integer)
Format/parse as 32-bit integer
NumberFormatter::TYPE_INT64 (integer)
Format/parse as 64-bit integer
NumberFormatter::TYPE_DOUBLE (integer)
Format/parse as floating point value
NumberFormatter::TYPE_CURRENCY (integer)
Format/parse as currency value

Number format attribute used by numfmt_get_attribute() and numfmt_set_attribute().

NumberFormatter::PARSE_INT_ONLY (integer)
Parse integers only.
NumberFormatter::GROUPING_USED (integer)
Use grouping separator.
NumberFormatter::DECIMAL_ALWAYS_SHOWN (integer)
Always show decimal point.
NumberFormatter::MAX_INTEGER_DIGITS (integer)
Maximum integer digits.
NumberFormatter::MIN_INTEGER_DIGITS (integer)
Minimum integer digits.
NumberFormatter::INTEGER_DIGITS (integer)
Integer digits.
NumberFormatter::MAX_FRACTION_DIGITS (integer)
Maximum fraction digits.
NumberFormatter::MIN_FRACTION_DIGITS (integer)
Minimum fraction digits.
NumberFormatter::FRACTION_DIGITS (integer)
Fraction digits.
NumberFormatter::MULTIPLIER (integer)
Multiplier.
NumberFormatter::GROUPING_SIZE (integer)
Grouping size.
NumberFormatter::ROUNDING_MODE (integer)
Rounding Mode.
NumberFormatter::ROUNDING_INCREMENT (integer)
Rounding increment.
NumberFormatter::FORMAT_WIDTH (integer)
The width to which the output of format() is padded.
NumberFormatter::PADDING_POSITION (integer)
The position at which padding will take place. See pad position constants for possible argument values.
NumberFormatter::SECONDARY_GROUPING_SIZE (integer)
Secondary grouping size.
NumberFormatter::SIGNIFICANT_DIGITS_USED (integer)
Use significant digits.
NumberFormatter::MIN_SIGNIFICANT_DIGITS (integer)
Minimum significant digits.
NumberFormatter::MAX_SIGNIFICANT_DIGITS (integer)
Maximum significant digits.
NumberFormatter::LENIENT_PARSE (integer)
Lenient parse mode used by rule-based formats.

Number format text attribute used by numfmt_get_text_attribute() and numfmt_set_text_attribute().

NumberFormatter::POSITIVE_PREFIX (integer)
Positive prefix.
NumberFormatter::POSITIVE_SUFFIX (integer)
Positive suffix.
NumberFormatter::NEGATIVE_PREFIX (integer)
Negative prefix.
NumberFormatter::NEGATIVE_SUFFIX (integer)
Negative suffix.
NumberFormatter::PADDING_CHARACTER (integer)
The character used to pad to the format width.
NumberFormatter::CURRENCY_CODE (integer)
The ISO currency code.
NumberFormatter::DEFAULT_RULESET (integer)
The default rule set. This is only available with rule-based formatters.
NumberFormatter::PUBLIC_RULESETS (integer)
The public rule sets. This is only available with rule-based formatters. This is a read-only attribute. The public rulesets are returned as a single string, with each ruleset name delimited by ';' (semicolon).

Number format symbols used by numfmt_get_symbol() and numfmt_set_symbol().

NumberFormatter::DECIMAL_SEPARATOR_SYMBOL (integer)
The decimal separator.
NumberFormatter::GROUPING_SEPARATOR_SYMBOL (integer)
The grouping separator.
NumberFormatter::PATTERN_SEPARATOR_SYMBOL (integer)
The pattern separator.
NumberFormatter::PERCENT_SYMBOL (integer)
The percent sign.
NumberFormatter::ZERO_DIGIT_SYMBOL (integer)
Zero.
NumberFormatter::DIGIT_SYMBOL (integer)
Character representing a digit in the pattern.
NumberFormatter::MINUS_SIGN_SYMBOL (integer)
The minus sign.
NumberFormatter::PLUS_SIGN_SYMBOL (integer)
The plus sign.
NumberFormatter::CURRENCY_SYMBOL (integer)
The currency symbol.
NumberFormatter::INTL_CURRENCY_SYMBOL (integer)
The international currency symbol.
NumberFormatter::MONETARY_SEPARATOR_SYMBOL (integer)
The monetary separator.
NumberFormatter::EXPONENTIAL_SYMBOL (integer)
The exponential symbol.
NumberFormatter::PERMILL_SYMBOL (integer)
Per mill symbol.
NumberFormatter::PAD_ESCAPE_SYMBOL (integer)
Escape padding character.
NumberFormatter::INFINITY_SYMBOL (integer)
Infinity symbol.
NumberFormatter::NAN_SYMBOL (integer)
Not-a-number symbol.
NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL (integer)
Significant digit symbol.
NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL (integer)
The monetary grouping separator.

Rounding mode values used by numfmt_get_attribute() and numfmt_set_attribute() with NumberFormatter::ROUNDING_MODE attribute.

NumberFormatter::ROUND_CEILING (integer)
Rounding mode to round towards positive infinity.
NumberFormatter::ROUND_DOWN (integer)
Rounding mode to round towards zero.
NumberFormatter::ROUND_FLOOR (integer)
Rounding mode to round towards negative infinity.
NumberFormatter::ROUND_HALFDOWN (integer)
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
NumberFormatter::ROUND_HALFEVEN (integer)
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
NumberFormatter::ROUND_HALFUP (integer)
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
NumberFormatter::ROUND_UP (integer)
Rounding mode to round away from zero.

Pad position values used by numfmt_get_attribute() and numfmt_set_attribute() with NumberFormatter::PADDING_POSITION attribute.

NumberFormatter::PAD_AFTER_PREFIX (integer)
Pad characters inserted after the prefix.
NumberFormatter::PAD_AFTER_SUFFIX (integer)
Pad characters inserted after the suffix.
NumberFormatter::PAD_BEFORE_PREFIX (integer)
Pad characters inserted before the prefix.
NumberFormatter::PAD_BEFORE_SUFFIX (integer)
Pad characters inserted before the suffix.


NumberFormatter::create

numfmt_create

NumberFormatter::__construct

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::create -- numfmt_create -- NumberFormatter::__constructCreate a number formatter

Description

Object oriented style (method)

public static NumberFormatter::create ( string $locale , int $style [, string $pattern ] ) : NumberFormatter

Procedural style

numfmt_create ( string $locale , int $style [, string $pattern ] ) : NumberFormatter

Object oriented style (constructor):

public NumberFormatter::__construct ( string $locale , int $style [, string $pattern ] )

Creates a number formatter.

Parameters

locale

Locale in which the number would be formatted (locale name, e.g. en_CA).

style

Style of the formatting, one of the format style constants. If NumberFormatter::PATTERN_DECIMAL or NumberFormatter::PATTERN_RULEBASED is passed then the number format is opened using the given pattern, which must conform to the syntax described in » ICU DecimalFormat documentation or » ICU RuleBasedNumberFormat documentation, respectively.

pattern

Pattern string if the chosen style requires a pattern.

Return Values

Returns NumberFormatter object or FALSE on error.

Examples

Example #1 numfmt_create() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
$fmt numfmt_create'it'NumberFormatter::SPELLOUT );
echo 
numfmt_format($fmt1142)."\n";
?>

Example #2 NumberFormatter::create() example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt = new NumberFormatter'it'NumberFormatter::SPELLOUT );
echo 
$fmt->format(1142)."\n";
?>

The above example will output:

   1.234.567,891
   millicentoquarantadue
   

See Also



NumberFormatter::formatCurrency

numfmt_format_currency

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::formatCurrency -- numfmt_format_currencyFormat a currency value

Description

Object oriented style

public NumberFormatter::formatCurrency ( float $value , string $currency ) : string

Procedural style

numfmt_format_currency ( NumberFormatter $fmt , float $value , string $currency ) : string

Format the currency value according to the formatter rules.

Parameters

fmt

NumberFormatter object.

value

The numeric currency value.

currency

The 3-letter ISO 4217 currency code indicating the currency to use.

Return Values

String representing the formatted currency value, or FALSE on failure.

Examples

Example #1 numfmt_format_currency() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::CURRENCY );
echo 
numfmt_format_currency($fmt1234567.891234567890000"EUR")."\n";
echo 
numfmt_format_currency($fmt1234567.891234567890000"RUR")."\n";
$fmt numfmt_create'ru_RU'NumberFormatter::CURRENCY );
echo 
numfmt_format_currency($fmt1234567.891234567890000"EUR")."\n";
echo 
numfmt_format_currency($fmt1234567.891234567890000"RUR")."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::CURRENCY );
echo 
$fmt->formatCurrency(1234567.891234567890000"EUR")."\n";
echo 
$fmt->formatCurrency(1234567.891234567890000"RUR")."\n";
$fmt = new NumberFormatter'ru_RU'NumberFormatter::CURRENCY );
echo 
$fmt->formatCurrency(1234567.891234567890000"EUR")."\n";
echo 
$fmt->formatCurrency(1234567.891234567890000"RUR")."\n";
?>

The above example will output:

   1.234.567,89 €
   1.234.567,89 RUR
   1 234 567,89€
   1 234 567,89р.
   

See Also



NumberFormatter::format

numfmt_format

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::format -- numfmt_formatFormat a number

Description

Object oriented style

public NumberFormatter::format ( number $value [, int $type ] ) : string

Procedural style

numfmt_format ( NumberFormatter $fmt , number $value [, int $type ] ) : string

Format a numeric value according to the formatter rules.

Parameters

fmt

NumberFormatter object.

value

The value to format. Can be integer or float, other values will be converted to a numeric value.

type

The formatting type to use.

Return Values

Returns the string containing formatted value, or FALSE on error.

Examples

Example #1 numfmt_format() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
$data numfmt_format($fmt1234567.891234567890000);
if(
intl_is_failure(numfmt_format($fmt))) {
    
report_error("Formatter error");
}
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
if(
intl_is_failure($fmt->getErrorCode())) {
    
report_error("Formatter error");
}
?>

The above example will output:

   1.234.567,891
   

See Also



NumberFormatter::getAttribute

numfmt_get_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getAttribute -- numfmt_get_attributeGet an attribute

Description

Object oriented style

public NumberFormatter::getAttribute ( int $attr ) : int

Procedural style

numfmt_get_attribute ( NumberFormatter $fmt , int $attr ) : int

Get a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce.

Parameters

fmt

NumberFormatter object.

attr

Attribute specifier - one of the numeric attribute constants.

Return Values

Return attribute value on success, or FALSE on error.

Examples

Example #1 numfmt_get_attribute() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Digits: ".numfmt_get_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS2);
echo 
"Digits: ".numfmt_get_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS2);
echo 
"Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Digits: 3
   1.234.567,891
   Digits: 2
   1.234.567,89
   

See Also



NumberFormatter::getErrorCode

numfmt_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getErrorCode -- numfmt_get_error_codeGet formatter's last error code

Description

Object oriented style

public NumberFormatter::getErrorCode ( void ) : int

Procedural style

numfmt_get_error_code ( NumberFormatter $fmt ) : int

Get error code from the last function performed by the formatter.

Parameters

fmt

NumberFormatter object.

Return Values

Returns error code from last formatter call.

Examples

Example #1 numfmt_get_error_code() example

<?php
$fmt  
numfmt_create'de_DE'NumberFormatter::DECIMAL );
$data numfmt_format($fmt1234567.891234567890000);
if(
intl_is_failure(numfmt_get_error_code($fmt))) {
    
report_error("Formatter error");
}
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
if(
intl_is_failure($fmt->getErrorCode())) {
    
report_error("Formatter error");
}
?>

See Also



NumberFormatter::getErrorMessage

numfmt_get_error_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getErrorMessage -- numfmt_get_error_messageGet formatter's last error message

Description

Object oriented style

public NumberFormatter::getErrorMessage ( void ) : string

Procedural style

numfmt_get_error_message ( NumberFormatter $fmt ) : string

Get error message from the last function performed by the formatter.

Parameters

fmt

NumberFormatter object.

Return Values

Returns error message from last formatter call.

Examples

Example #1 numfmt_get_error_message() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
$data numfmt_format($fmt1234567.891234567890000);
var_dump(numfmt_get_error_message($fmt));
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
$fmt->format(1234567.891234567890000);
var_dump(numfmt_get_error_message($fmt));
?>

See Also



NumberFormatter::getLocale

numfmt_get_locale

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getLocale -- numfmt_get_localeGet formatter locale

Description

Object oriented style

public NumberFormatter::getLocale ([ int $type ] ) : string

Procedural style

numfmt_get_locale ( NumberFormatter $fmt [, int $type ] ) : string

Get formatter locale name.

Parameters

fmt

NumberFormatter object.

type

You can choose between valid and actual locale ( Locale::VALID_LOCALE, Locale::ACTUAL_LOCALE, respectively). The default is the actual locale.

Return Values

The locale name used to create the formatter.

Examples

Example #1 numfmt_get_locale() example

<?php
$req     
'fr_FR_PARIS';
$fmt     numfmt_create$req,  NumberFormatter::DECIMAL);
$res_val numfmt_get_locale$fmtLocale::VALID_LOCALE );
$res_act numfmt_get_locale$fmtLocale::ACTUAL_LOCALE );
printf"Requested locale name: %s\nValid locale name: %s\nActual locale name: %s\n",
         
$req$res_val$res_act );
?>

The above example will output:

   Requested locale name: fr_FR_PARIS
   Valid locale name: fr_FR
   Actual locale name: fr
   

See Also



NumberFormatter::getPattern

numfmt_get_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getPattern -- numfmt_get_patternGet formatter pattern

Description

Object oriented style

public NumberFormatter::getPattern ( void ) : string

Procedural style

numfmt_get_pattern ( NumberFormatter $fmt ) : string

Extract pattern used by the formatter.

Parameters

fmt

NumberFormatter object.

Return Values

Pattern string that is used by the formatter, or FALSE if an error happens.

Examples

Example #1 numfmt_get_pattern() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Pattern: ".numfmt_get_pattern($fmt)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_pattern($fmt"#0.# kg");
echo 
"Pattern: ".numfmt_get_pattern($fmt)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Pattern: ".$fmt->getPattern()."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setPattern("#0.# kg");
echo 
"Pattern: ".$fmt->getPattern()."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Pattern: #,##0.###
   1.234.567,891
   Pattern: #0.# kg
   1234567,9 kg
   

See Also



NumberFormatter::getSymbol

numfmt_get_symbol

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getSymbol -- numfmt_get_symbolGet a symbol value

Description

Object oriented style

public NumberFormatter::getSymbol ( int $attr ) : string

Procedural style

numfmt_get_symbol ( NumberFormatter $fmt , int $attr ) : string

Get a symbol associated with the formatter. The formatter uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.

Parameters

fmt

NumberFormatter object.

attr

Symbol specifier, one of the format symbol constants.

Return Values

The symbol string or FALSE on error.

Examples

Example #1 numfmt_get_symbol() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Sep: ".numfmt_get_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL"*");
echo 
"Sep: ".numfmt_get_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL"*");
echo 
"Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Sep: .
   1.234.567,891
   Sep: *
   1*234*567,891
   

See Also



NumberFormatter::getTextAttribute

numfmt_get_text_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::getTextAttribute -- numfmt_get_text_attributeGet a text attribute

Description

Object oriented style

public NumberFormatter::getTextAttribute ( int $attr ) : string

Procedural style

numfmt_get_text_attribute ( NumberFormatter $fmt , int $attr ) : string

Get a text attribute associated with the formatter. An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, U_UNSUPPORTED_ERROR error is produced. Rule-based formatters only understand NumberFormatter::DEFAULT_RULESET and NumberFormatter::PUBLIC_RULESETS.

Parameters

fmt

NumberFormatter object.

attr

Attribute specifier - one of the text attribute constants.

Return Values

Return attribute value on success, or FALSE on error.

Examples

Example #1 numfmt_get_text_attribute() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Prefix: ".numfmt_get_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
numfmt_format($fmt, -1234567.891234567890000)."\n";
numfmt_set_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX"MINUS");
echo 
"Prefix: ".numfmt_get_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
numfmt_format($fmt, -1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
$fmt->format(-1234567.891234567890000)."\n";
$fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX"MINUS");
echo 
"Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
$fmt->format(-1234567.891234567890000)."\n";
?>

The above example will output:

   Prefix: -
   -1.234.567,891
   Prefix: MINUS
   MINUS1.234.567,891
   

See Also



NumberFormatter::parseCurrency

numfmt_parse_currency

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::parseCurrency -- numfmt_parse_currencyParse a currency number

Description

Object oriented style

public NumberFormatter::parseCurrency ( string $value , string &$currency [, int &$position ] ) : float

Procedural style

numfmt_parse_currency ( NumberFormatter $fmt , string $value , string &$currency [, int &$position ] ) : float

Parse a string into a double and a currency using the current formatter.

Parameters

fmt

NumberFormatter object.

currency

Parameter to receive the currency name (3-letter ISO 4217 currency code).

position

Offset in the string at which to begin parsing. On return, this value will hold the offset at which parsing ended.

Return Values

The parsed numeric value or FALSE on error.

Examples

Example #1 numfmt_parse_currency() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::CURRENCY );
$num "1.234.567,89\xc2\xa0$";
echo 
"We have ".numfmt_parse_currency($fmt$num$curr)." in $curr\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::CURRENCY );
$num "1.234.567,89\xc2\xa0$";
echo 
"We have ".$fmt->parseCurrency($num$curr)." in $curr\n";
?>

The above example will output:

   We have 1234567.89 in USD
   

See Also



NumberFormatter::parse

numfmt_parse

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::parse -- numfmt_parseParse a number

Description

Object oriented style

public NumberFormatter::parse ( string $value [, int $type [, int &$position ]] ) : mixed

Procedural style

numfmt_parse ( NumberFormatter $fmt , string $value [, int $type [, int &$position ]] ) : mixed

Parse a string into a number using the current formatter rules.

Parameters

fmt

NumberFormatter object.

type

The formatting type to use. By default, NumberFormatter::TYPE_DOUBLE is used.

position

Offset in the string at which to begin parsing. On return, this value will hold the offset at which parsing ended.

Return Values

The value of the parsed number or FALSE on error.

Examples

Example #1 numfmt_parse() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
$num "1.234.567,891";
echo 
numfmt_parse($fmt$num)."\n";
echo 
numfmt_parse($fmt$numNumberFormatter::TYPE_INT32)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
$num "1.234.567,891";
echo 
$fmt->parse($num)."\n";
echo 
$fmt->parse($numNumberFormatter::TYPE_INT32)."\n";
?>

The above example will output:

   1234567.891
   1234567
   

See Also



NumberFormatter::setAttribute

numfmt_set_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::setAttribute -- numfmt_set_attributeSet an attribute

Description

Object oriented style

public NumberFormatter::setAttribute ( int $attr , int $value ) : bool

Procedural style

numfmt_set_attribute ( NumberFormatter $fmt , int $attr , int $value ) : bool

Set a numeric attribute associated with the formatter. An example of a numeric attribute is the number of integer digits the formatter will produce.

Parameters

fmt

NumberFormatter object.

attr

Attribute specifier - one of the numeric attribute constants.

value

The attribute value.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 numfmt_set_attribute() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Digits: ".numfmt_get_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS2);
echo 
"Digits: ".numfmt_get_attribute($fmtNumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS2);
echo 
"Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Digits: 3
   1.234.567,891
   Digits: 2
   1.234.567,89
   

See Also



NumberFormatter::setPattern

numfmt_set_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::setPattern -- numfmt_set_patternSet formatter pattern

Description

Object oriented style

public NumberFormatter::setPattern ( string $pattern ) : bool

Procedural style

numfmt_set_pattern ( NumberFormatter $fmt , string $pattern ) : bool

Set the pattern used by the formatter. Can not be used on a rule-based formatter.

Parameters

fmt

NumberFormatter object.

pattern

Pattern in syntax described in » ICU DecimalFormat documentation.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 numfmt_set_pattern() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Pattern: ".numfmt_get_pattern($fmt)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_pattern($fmt"#0.# kg");
echo 
"Pattern: ".numfmt_get_pattern($fmt)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Pattern: ".$fmt->getPattern()."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setPattern("#0.# kg");
echo 
"Pattern: ".$fmt->getPattern()."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Pattern: #,##0.###
   1.234.567,891
   Pattern: #0.# kg
   1234567,9 kg
   

See Also



NumberFormatter::setSymbol

numfmt_set_symbol

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::setSymbol -- numfmt_set_symbolSet a symbol value

Description

Object oriented style

public NumberFormatter::setSymbol ( int $attr , string $value ) : bool

Procedural style

numfmt_set_symbol ( NumberFormatter $fmt , int $attr , string $value ) : bool

Set a symbol associated with the formatter. The formatter uses symbols to represent the special locale-dependent characters in a number, for example the percent sign. This API is not supported for rule-based formatters.

Parameters

fmt

NumberFormatter object.

attr

Symbol specifier, one of the format symbol constants.

value

Text for the symbol.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 numfmt_set_symbol() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Sep: ".numfmt_get_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
numfmt_set_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL"*");
echo 
"Sep: ".numfmt_get_symbol($fmtNumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
numfmt_format($fmt1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
$fmt->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL"*");
echo 
"Sep: ".$fmt->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL)."\n";
echo 
$fmt->format(1234567.891234567890000)."\n";
?>

The above example will output:

   Sep: .
   1.234.567,891
   Sep: *
   1*234*567,891
   

See Also



NumberFormatter::setTextAttribute

numfmt_set_text_attribute

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

NumberFormatter::setTextAttribute -- numfmt_set_text_attributeSet a text attribute

Description

Object oriented style

public NumberFormatter::setTextAttribute ( int $attr , string $value ) : bool

Procedural style

numfmt_set_text_attribute ( NumberFormatter $fmt , int $attr , string $value ) : bool

Set a text attribute associated with the formatter. An example of a text attribute is the suffix for positive numbers. If the formatter does not understand the attribute, U_UNSUPPORTED_ERROR error is produced. Rule-based formatters only understand NumberFormatter::DEFAULT_RULESET and NumberFormatter::PUBLIC_RULESETS.

Parameters

fmt

NumberFormatter object.

attr

Attribute specifier - one of the text attribute constants.

value

Text for the attribute value.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 numfmt_set_text_attribute() example

<?php
$fmt 
numfmt_create'de_DE'NumberFormatter::DECIMAL );
echo 
"Prefix: ".numfmt_get_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
numfmt_format($fmt, -1234567.891234567890000)."\n";
numfmt_set_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX"MINUS");
echo 
"Prefix: ".numfmt_get_text_attribute($fmtNumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
numfmt_format($fmt, -1234567.891234567890000)."\n";
?>

Example #2 OO example

<?php
$fmt 
= new NumberFormatter'de_DE'NumberFormatter::DECIMAL );
echo 
"Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
$fmt->format(-1234567.891234567890000)."\n";
$fmt->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX"MINUS");
echo 
"Prefix: ".$fmt->getTextAttribute(NumberFormatter::NEGATIVE_PREFIX)."\n";
echo 
$fmt->format(-1234567.891234567890000)."\n";
?>

The above example will output:

   Prefix: -
   -1.234.567,891
   Prefix: MINUS
   MINUS1.234.567,891
   

See Also


Table of Contents



The Locale class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

A "Locale" is an identifier used to get language, culture, or regionally-specific behavior from an API. PHP locales are organized and identified the same way that the CLDR locales used by ICU (and many vendors of Unix-like operating systems, the Mac, Java, and so forth) use. Locales are identified using RFC 4646 language tags (which use hyphen, not underscore) in addition to the more traditional underscore-using identifiers. Unless otherwise noted the functions in this class are tolerant of both formats.

Examples of identifiers include:

  • en-US (English, United States)
  • zh-Hant-TW (Chinese, Traditional Script, Taiwan)
  • fr-CA, fr-FR (French for Canada and France respectively)

The Locale class (and related procedural functions) are used to interact with locale identifiers--to verify that an ID is well-formed, valid, etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are valid and used wherever they would be in ICU normally.

Locales cannot be instantiated as objects. All of the functions/methods provided are static.

The null or empty string obtains the "root" locale. The "root" locale is equivalent to "en_US_POSIX" in CLDR. Language tags (and thus locale identifiers) are case insensitive. There exists a canonicalization function to make case match the specification.

Class synopsis

Locale {
/* Methods */
public static acceptFromHttp ( string $header ) : string
public static canonicalize ( string $locale ) : string
public static composeLocale ( array $subtags ) : string
public static filterMatches ( string $langtag , string $locale [, bool $canonicalize = FALSE ] ) : bool
public static getAllVariants ( string $locale ) : array
public static getDefault ( void ) : string
public static getDisplayLanguage ( string $locale [, string $in_locale ] ) : string
public static getDisplayName ( string $locale [, string $in_locale ] ) : string
public static getDisplayRegion ( string $locale [, string $in_locale ] ) : string
public static getDisplayScript ( string $locale [, string $in_locale ] ) : string
public static getDisplayVariant ( string $locale [, string $in_locale ] ) : string
public static getKeywords ( string $locale ) : array
public static getPrimaryLanguage ( string $locale ) : string
public static getRegion ( string $locale ) : string
public static getScript ( string $locale ) : string
public static lookup ( array $langtag , string $locale [, bool $canonicalize = FALSE [, string $default ]] ) : string
public static parseLocale ( string $locale ) : array
public static setDefault ( string $locale ) : bool
}

Predefined Constants

Locale::DEFAULT_LOCALE (null)
Used as locale parameter with the methods of the various locale affected classes, such as NumberFormatter. This constant would make the methods to use default locale.

These constants describe the choice of the locale for the getLocale method of different classes.

Locale::ACTUAL_LOCALE (string)
This is locale the data actually comes from.
Locale::VALID_LOCALE (string)
This is the most specific locale supported by ICU.

These constants define how the Locales are parsed or composed. They should be used as keys in the argument array to locale_compose() and are returned from locale_parse() as keys of the returned associative array.

Locale::LANG_TAG (string)
Language subtag
Locale::EXTLANG_TAG (string)
Extended language subtag
Locale::SCRIPT_TAG (string)
Script subtag
Locale::REGION_TAG (string)
Region subtag
Locale::VARIANT_TAG (string)
Variant subtag
Locale::GRANDFATHERED_LANG_TAG (string)
Grandfathered Language subtag
Locale::PRIVATE_TAG (string)
Private subtag


Locale::acceptFromHttp

locale_accept_from_http

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::acceptFromHttp -- locale_accept_from_httpTries to find out best available locale based on HTTP "Accept-Language" header

Description

Object oriented style

public static Locale::acceptFromHttp ( string $header ) : string

Procedural style

locale_accept_from_http ( string $header ) : string

Tries to find locale that can satisfy the language list that is requested by the HTTP "Accept-Language" header.

Parameters

header

The string containing the "Accept-Language" header according to format in RFC 2616.

Return Values

The corresponding locale identifier.

Examples

Example #1 locale_accept_from_http() example

<?php
$locale 
locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo 
$locale;
?>

Example #2 OO example

<?php
$locale 
Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo 
$locale;
?>

The above example will output:

   en_US
   

See Also

  • locale_lookup() - Searches the language tag list for the best match to the language



Locale::canonicalize

locale_canonicalize

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::canonicalize -- locale_canonicalizeCanonicalize the locale string

Description

public static Locale::canonicalize ( string $locale ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



Locale::composeLocale

locale_compose

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::composeLocale -- locale_composeReturns a correctly ordered and delimited locale ID

Description

Object oriented style

public static Locale::composeLocale ( array $subtags ) : string

Procedural style

locale_compose ( array $subtags ) : string

Returns a correctly ordered and delimited locale ID the keys identify the particular locale ID subtags, and the values are the associated subtag values.

Parameters

subtags

an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values.

Note:

The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.e.g. Variants are allowed with the suffix ranging from 0-14. Hence the keys for the input array can be variant0, variant1, ...,variant14. In the returned locale id, the subtag is ordered by suffix resulting in variant0 followed by variant1 followed by variant2 and so on.

The 'variant', 'private' and 'extlang' multiple values can be specified both as array under specific key (e.g. 'variant') and as multiple numbered keys (e.g. 'variant0', 'variant1', etc.).

Return Values

The corresponding locale identifier.

Examples

Example #1 locale_compose() example

<?php
$arr 
= array(
    
'language'=>'en' ,
    
'script'  =>'Hans' ,
    
'region'  =>'CN',
    
'variant2'=>'rozaj' ,
    
'variant1'=>'nedis' ,
    
'private1'=>'prv1' ,
    
'private2'=>'prv2'
);
echo 
locale_compose$arr );
?>

Example #2 OO example

<?php
$arr 
= array(
    
'language'=>'en' ,
    
'script'  =>'Hans' ,
    
'region'  =>'CN',
    
'variant2'=>'rozaj' ,
    
'variant1'=>'nedis' ,
    
'private1'=>'prv1' ,
    
'private2'=>'prv2'
);
echo 
Locale::composeLocale$arr );
?>

The above example will output:

   Locale: en_Hans_CN_nedis_rozaj_x_prv1_prv2
   

See Also

  • locale_parse() - Returns a key-value array of locale ID subtag elements



Locale::filterMatches

locale_filter_matches

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::filterMatches -- locale_filter_matchesChecks if a language tag filter matches with locale

Description

Object oriented style

public static Locale::filterMatches ( string $langtag , string $locale [, bool $canonicalize = FALSE ] ) : bool

Procedural style

locale_filter_matches ( string $langtag , string $locale [, bool $canonicalize = FALSE ] ) : bool

Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm

Parameters

langtag

The language tag to check

locale

The language range to check against

canonicalize

If true, the arguments will be converted to canonical form before matching.

Return Values

TRUE if $locale matches $langtag FALSE otherwise.

Examples

Example #1 locale_filter_matches() example

<?php
echo (locale_filter_matches('de-DEVA','de-DE'false)) ? "Matches" "Does not match"
echo 
'; ';
echo (
locale_filter_matches('de-DE_1996','de-DE'false)) ? "Matches" "Does not match"
?>

Example #2 OO example

<?php
echo (Locale::filterMatches('de-DEVA','de-DE'false)) ? "Matches" "Does not match"
echo 
'; ';
echo (
Locale::filterMatches('de-DE-1996','de-DE'false)) ? "Matches" "Does not match"
?>

The above example will output:

   Does not match; Matches
   

See Also

  • locale_lookup() - Searches the language tag list for the best match to the language



Locale::getAllVariants

locale_get_all_variants

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getAllVariants -- locale_get_all_variantsGets the variants for the input locale

Description

Object oriented style

public static Locale::getAllVariants ( string $locale ) : array

Procedural style

locale_get_all_variants ( string $locale ) : array

Gets the variants for the input locale

Parameters

locale

The locale to extract the variants from

Return Values

The array containing the list of all variants subtag for the locale or NULL if not present

Examples

Example #1 locale_get_all_variants() example

<?php
$arr 
locale_get_all_variants('sl_IT_NEDIS_ROJAZ_1901');
var_export$arr );
?>

Example #2 OO example

<?php
 $arr 
Locale::getAllVariants('sl_IT_NEDIS_ROJAZ_1901');
 
var_export$arr );
?>

The above example will output:

   array (
       0 => 'NEDIS',
       1 => 'ROJAZ',
       2 => '1901',
   )
   

See Also



Locale::getDefault

locale_get_default

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDefault -- locale_get_defaultGets the default locale value from the INTL global 'default_locale'

Description

Object oriented style

public static Locale::getDefault ( void ) : string

Procedural style

locale_get_default ( void ) : string

Gets the default locale value. At the PHP initialization this value is set to 'intl.default_locale' value from php.ini if that value exists or from ICU's function uloc_getDefault().

Parameters

Return Values

The current runtime locale

Examples

Example #1 locale_get_default() example

<?php
ini_set
('intl.default_locale''de-DE');
echo 
locale_get_default();
echo 
'; ';
locale_set_default('fr');
echo 
locale_get_default();
?>

Example #2 OO example

<?php
ini_set
('intl.default_locale''de-DE');
echo 
Locale::getDefault();
echo 
'; ';
Locale::setDefault('fr');
echo 
Locale::getDefault();
?>

The above example will output:

   de-DE; fr
   

See Also



Locale::getDisplayLanguage

locale_get_display_language

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDisplayLanguage -- locale_get_display_languageReturns an appropriately localized display name for language of the inputlocale

Description

Object oriented style

public static Locale::getDisplayLanguage ( string $locale [, string $in_locale ] ) : string

Procedural style

locale_get_display_language ( string $locale [, string $in_locale ] ) : string

Returns an appropriately localized display name for language of the input locale. If is NULL then the default locale is used.

Parameters

locale

The locale to return a display language for

in_locale

Optional format locale to use to display the language name

Return Values

display name of the language for the $locale in the format appropriate for $in_locale.

Examples

Example #1 locale_get_display_language() example

<?php
echo locale_get_display_language('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
locale_get_display_language('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
locale_get_display_language('sl-Latn-IT-nedis''de');
?>

Example #2 OO example

<?php
echo Locale::getDisplayLanguage('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
Locale::getDisplayLanguage('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
Locale::getDisplayLanguage('sl-Latn-IT-nedis''de');
?>

The above example will output:

   Slovenian;
   slov\xc3\xa8ne;
   Slowenisch
   

See Also



Locale::getDisplayName

locale_get_display_name

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDisplayName -- locale_get_display_nameReturns an appropriately localized display name for the input locale

Description

Object oriented style

public static Locale::getDisplayName ( string $locale [, string $in_locale ] ) : string

Procedural style

locale_get_display_name ( string $locale [, string $in_locale ] ) : string

Returns an appropriately localized display name for the input locale. If $locale is NULL then the default locale is used.

Parameters

locale

The locale to return a display name for.

in_locale

optional format locale

Return Values

Display name of the locale in the format appropriate for $in_locale.

Examples

Example #1 locale_get_display_name() example

<?php
echo locale_get_display_name('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
locale_get_display_name('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
locale_get_display_name('sl-Latn-IT-nedis''de');
?>

Example #2 OO example

<?php
echo Locale::getDisplayName('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
Locale::getDisplayName('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
Locale::getDisplayName('sl-Latn-IT-nedis''de');
?>

The above example will output:

   Slovenian (Latin, Italy, Natisone dialect);
   slov\xc3\xa8ne (latin, Italie, dialecte de Natisone;
   Slowenisch (Lateinisch, Italien, NEDIS)
     

See Also



Locale::getDisplayRegion

locale_get_display_region

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDisplayRegion -- locale_get_display_regionReturns an appropriately localized display name for region of the input locale

Description

Object oriented style

public static Locale::getDisplayRegion ( string $locale [, string $in_locale ] ) : string

Procedural style

locale_get_display_region ( string $locale [, string $in_locale ] ) : string

Returns an appropriately localized display name for region of the input locale. If is NULL then the default locale is used.

Parameters

locale

The locale to return a display region for.

in_locale

Optional format locale to use to display the region name

Return Values

display name of the region for the $locale in the format appropriate for $in_locale.

Examples

Example #1 locale_get_display_region() example

<?php
echo locale_get_display_region('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
locale_get_display_region('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
locale_get_display_region('sl-Latn-IT-nedis''de');
?>

Example #2 OO example

<?php
echo Locale::getDisplayRegion('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
Locale::getDisplayRegion('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
Locale::getDisplayRegion('sl-Latn-IT-nedis''de');
?>

The above example will output:

   Italy;
   Italie;
   Italien
   

See Also



Locale::getDisplayScript

locale_get_display_script

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDisplayScript -- locale_get_display_scriptReturns an appropriately localized display name for script of the input locale

Description

Object oriented style

public static Locale::getDisplayScript ( string $locale [, string $in_locale ] ) : string

Procedural style

locale_get_display_script ( string $locale [, string $in_locale ] ) : string

Returns an appropriately localized display name for script of the input locale. If is NULL then the default locale is used.

Parameters

locale

The locale to return a display script for

in_locale

Optional format locale to use to display the script name

Return Values

Display name of the script for the $locale in the format appropriate for $in_locale.

Examples

Example #1 locale_get_display_script() example

<?php
echo locale_get_display_script('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
locale_get_display_script('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
locale_get_display_script('sl-Latn-IT-nedis''de');
?>

Example #2 OO example

<?php
echo Locale::getDisplayScript('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
Locale::getDisplayScript('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
Locale::getDisplayScript('sl-Latn-IT-nedis''de');
?>

The above example will output:

   Latin;
   latin;
   Lateinisch
   

See Also



Locale::getDisplayVariant

locale_get_display_variant

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getDisplayVariant -- locale_get_display_variantReturns an appropriately localized display name for variants of the input locale

Description

Object oriented style

public static Locale::getDisplayVariant ( string $locale [, string $in_locale ] ) : string

Procedural style

locale_get_display_variant ( string $locale [, string $in_locale ] ) : string

Returns an appropriately localized display name for variants of the input locale. If is NULL then the default locale is used.

Parameters

locale

The locale to return a display variant for

in_locale

Optional format locale to use to display the variant name

Return Values

Display name of the variant for the $locale in the format appropriate for $in_locale.

Examples

Example #1 locale_get_display_variant() example

<?php
echo locale_get_display_variant('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
locale_get_display_variant('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
locale_get_display_variant('sl-Latn-IT-nedis''de');
?>

Example #2 OO example

<?php
echo Locale::getDisplayVariant('sl-Latn-IT-nedis''en');
echo 
";\n";
echo 
Locale::getDisplayVariant('sl-Latn-IT-nedis''fr');
echo 
";\n";
echo 
Locale::getDisplayVariant('sl-Latn-IT-nedis''de');
?>

The above example will output:

   Natisone dialect;
   dialecte de Natisone;
   NEDIS
     

See Also



Locale::getKeywords

locale_get_keywords

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getKeywords -- locale_get_keywordsGets the keywords for the input locale

Description

Object oriented style

public static Locale::getKeywords ( string $locale ) : array

Procedural style

locale_get_keywords ( string $locale ) : array

Gets the keywords for the input locale.

Parameters

locale

The locale to extract the keywords from

Return Values

Associative array containing the keyword-value pairs for this locale

Examples

Example #1 locale_get_keywords() example

<?php
$keywords_arr 
locale_get_keywords('de_DE@currency=EUR;collation=PHONEBOOK');
if (
$keywords_arr) {
    foreach (
$keywords_arr as $key => $value) {
        echo 
"$key = $value\n"
    }
}
?>

Example #2 OO example

<?php
$keywords_arr 
Locale::getKeywords('de_DE@currency=EUR;collation=PHONEBOOK');
if (
$keywords_arr) {
    foreach (
$keywords_arr as $key => $value) {
        echo 
"$key = $value\n"
    }
}
?>

The above example will output:

   collation = PHONEBOOK
   currency = EUR
   

See Also



Locale::getPrimaryLanguage

locale_get_primary_language

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getPrimaryLanguage -- locale_get_primary_languageGets the primary language for the input locale

Description

Object oriented style

public static Locale::getPrimaryLanguage ( string $locale ) : string

Procedural style

locale_get_primary_language ( string $locale ) : string

Gets the primary language for the input locale

Parameters

locale

The locale to extract the primary language code from

Return Values

The language code associated with the language or NULL in case of error.

Examples

Example #1 locale_get_primary_language() example

<?php
echo locale_get_primary_language('zh-Hant');
?>

Example #2 OO example

<?php
echo Locale::getPrimaryLanguage('zh-Hant');
?>

The above example will output:

   zh
   

See Also



Locale::getRegion

locale_get_region

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getRegion -- locale_get_regionGets the region for the input locale

Description

Object oriented style

public static Locale::getRegion ( string $locale ) : string

Procedural style

locale_get_region ( string $locale ) : string

Gets the region for the input locale.

Parameters

locale

The locale to extract the region code from

Return Values

The region subtag for the locale or NULL if not present

Examples

Example #1 locale_get_region() example

<?php
echo locale_get_region('de-CH-1901');
?>

Example #2 OO example

<?php
echo Locale::getRegion('de-CH-1901');
?>

The above example will output:

   CH
   

See Also



Locale::getScript

locale_get_script

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::getScript -- locale_get_scriptGets the script for the input locale

Description

Object oriented style

public static Locale::getScript ( string $locale ) : string

Procedural style

locale_get_script ( string $locale ) : string

Gets the script for the input locale.

Parameters

locale

The locale to extract the script code from

Return Values

The script subtag for the locale or NULL if not present

Examples

Example #1 locale_get_script() example

<?php
echo locale_get_script('sr-Cyrl');
?>

Example #2 OO example

<?php
echo Locale::getScript('sr-Cyrl');
?>

The above example will output:

   Cyrl
   

See Also



Locale::lookup

locale_lookup

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::lookup -- locale_lookupSearches the language tag list for the best match to the language

Description

Object oriented style

public static Locale::lookup ( array $langtag , string $locale [, bool $canonicalize = FALSE [, string $default ]] ) : string

Procedural style

locale_lookup ( array $langtag , string $locale [, bool $canonicalize = FALSE [, string $default ]] ) : string

Searches the items in langtag for the best match to the language range specified in locale according to RFC 4647's lookup algorithm.

Parameters

langtag

An array containing a list of language tags to compare to locale. Maximum 100 items allowed.

locale

The locale to use as the language range when matching.

canonicalize

If true, the arguments will be converted to canonical form before matching.

default

The locale to use if no match is found.

Return Values

The closest matching language tag or default value.

Examples

Example #1 locale_lookup() example

<?php
$arr 
= array(
    
'de-DEVA',
    
'de-DE-1996',
    
'de',
    
'de-De'
);
echo 
locale_lookup($arr'de-DE-1996-x-prv1-prv2'true'en_US');
?>

Example #2 OO example

<?php
$arr 
= array(
    
'de-DEVA',
    
'de-DE-1996',
    
'de',
    
'de-De'
);
echo 
Locale::lookup($arr'de-DE-1996-x-prv1-prv2'true'en_US');
?>

The above example will output:

   de_de_1996
   

See Also



Locale::parseLocale

locale_parse

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::parseLocale -- locale_parseReturns a key-value array of locale ID subtag elements

Description

Object oriented style

public static Locale::parseLocale ( string $locale ) : array

Procedural style

locale_parse ( string $locale ) : array

Returns a key-value array of locale ID subtag elements.

Parameters

locale

The locale to extract the subtag array from. Note: The 'variant' and 'private' subtags can take maximum 15 values whereas 'extlang' can take maximum 3 values.

Return Values

Returns an array containing a list of key-value pairs, where the keys identify the particular locale ID subtags, and the values are the associated subtag values. The array will be ordered as the locale id subtags e.g. in the locale id if variants are '-varX-varY-varZ' then the returned array will have variant0=>varX , variant1=>varY , variant2=>varZ

Returns NULL when the length of locale exceeds INTL_MAX_LOCALE_LEN.

Examples

Example #1 locale_parse() example

<?php
$arr 
locale_parse('sl-Latn-IT-nedis');
if (
$arr) {
    foreach (
$arr as $key => $value) {
        echo 
"$key : $value , ";
    }
}
?>

Example #2 OO example

<?php
$arr 
Locale::parseLocale('sl-Latn-IT-nedis');
if (
$arr) {
    foreach (
$arr as $key => $value) {
        echo 
"$key : $value , ";
    }
}
?>

The above example will output:

   language : sl , script : Latn , region : IT , variant0 : NEDIS ,
   

See Also



Locale::setDefault

locale_set_default

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Locale::setDefault -- locale_set_defaultSets the default runtime locale

Description

Object oriented style

public static Locale::setDefault ( string $locale ) : bool

Procedural style

locale_set_default ( string $locale ) : bool

Sets the default runtime locale to $locale. This changes the value of INTL global 'default_locale' locale identifier. UAX #35 extensions are accepted.

Parameters

locale

Is a BCP 47 compliant language tag.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 locale_set_default() example

<?php
locale_set_default
('de-DE');
echo 
locale_get_default();
?>

Example #2 OO example

<?php
Locale
::setDefault('de-DE');
echo 
Locale::getDefault();
?>

The above example will output:

   de-DE
   

See Also


Table of Contents



The Normalizer class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

Normalization is a process that involves transforming characters and sequences of characters into a formally-defined underlying representation. This process is most important when text needs to be compared for sorting and searching, but it is also used when storing text to ensure that the text is stored in a consistent representation.

The Unicode Consortium has defined a number of normalization forms reflecting the various needs of applications:

  • Normalization Form D (NFD) - Canonical Decomposition
  • Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition
  • Normalization Form KD (NFKD) - Compatibility Decomposition
  • Normalization Form KC (NFKC) - Compatibility Decomposition followed by Canonical Composition
The different forms are defined in terms of a set of transformations on the text, transformations that are expressed by both an algorithm and a set of data files.

Class synopsis

Normalizer {
/* Methods */
public static getRawDecomposition ( string $input ) : string
public static isNormalized ( string $input [, int $form = Normalizer::FORM_C ] ) : bool
public static normalize ( string $input [, int $form = Normalizer::FORM_C ] ) : string
}

Predefined Constants

The following constants define the normalization form used by the normalizer:

Normalizer::FORM_C (integer)
Normalization Form C (NFC) - Canonical Decomposition followed by Canonical Composition
Normalizer::FORM_D (integer)
Normalization Form D (NFD) - Canonical Decomposition
Normalizer::FORM_KC (integer)
Normalization Form KC (NFKC) - Compatibility Decomposition, followed by Canonical Composition
Normalizer::FORM_KD (integer)
Normalization Form KD (NFKD) - Compatibility Decomposition
Normalizer::NONE (integer)
No decomposition/composition
Normalizer::OPTION_DEFAULT (integer)
Default normalization options


Normalizer::getRawDecomposition

normalizer_get_raw_decomposition

(PHP 7 >= 7.3)

Normalizer::getRawDecomposition -- normalizer_get_raw_decompositionGets the Decomposition_Mapping property for the given UTF-8 encoded code point

Description

Object oriented style

public static Normalizer::getRawDecomposition ( string $input ) : string

Procedural style

normalizer_get_raw_decomposition ( string $input ) : string

Gets the Decomposition_Mapping property, as specified in the Unicode Character Database (UCD), for the given UTF-8 encoded code point.

Parameters

input

The input string, which should be a single, UTF-8 encoded, code point.

Return Values

Returns a string containing the Decomposition_Mapping property, if present in the UCD.

Returns NULL if there is no Decomposition_Mapping property for the character.

Examples

Example #1 Normalizer::getRawDecomposition() example

<?php

$result 
"";
$strings = [
    
"a",
    
"\u{FFDA}",
    
"\u{FDFA}",
    
"",
    
"aa",
    
"\xF5",
];

foreach (
$strings as $string) {
    
$decomposition Normalizer::getRawDecomposition($string);
    
// $decomposition = normalizer_get_raw_decomposition($string); Procedural way

    
$error_code intl_get_error_code();
    
$error_message intl_get_error_message();

    
$string_hex bin2hex($string);
    
$result .= "---------------------\n";

    if (
$decomposition === null) {
        
$result .= "'$string_hex' has no decomposition mapping\n" ;
    } else {
        
$result .= "'$string_hex' has the decomposition mapping '" bin2hex($decomposition) . "'\n" ;
    }

    
$result .= "error info: '$error_message' ($error_code)\n";
}

echo 
$result;
?>

The above example will output:

   ---------------------
   '61' has no decomposition mapping
   error info: 'U_ZERO_ERROR' (0)
   ---------------------
   'efbf9a' has the decomposition mapping 'e385a1'
   error info: 'U_ZERO_ERROR' (0)
   ---------------------
   'efb7ba' has the decomposition mapping 'd8b5d984d98920d8a7d984d984d98720d8b9d984d98ad98720d988d8b3d984d985'
   error info: 'U_ZERO_ERROR' (0)
   ---------------------
   '' has no decomposition mapping
   error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
   ---------------------
   '6161' has no decomposition mapping
   error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
   ---------------------
   'f5' has no decomposition mapping
   error info: 'Code point out of range: U_ILLEGAL_ARGUMENT_ERROR' (1)
   

See Also



Normalizer::isNormalized

normalizer_is_normalized

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Normalizer::isNormalized -- normalizer_is_normalized Checks if the provided string is already in the specified normalization form

Description

Object oriented style

public static Normalizer::isNormalized ( string $input [, int $form = Normalizer::FORM_C ] ) : bool

Procedural style

normalizer_is_normalized ( string $input [, int $form = Normalizer::FORM_C ] ) : bool

Checks if the provided string is already in the specified normalization form.

Parameters

input

The input string to normalize

form

One of the normalization forms.

Return Values

TRUE if normalized, FALSE otherwise or if there an error

Examples

Example #1 normalizer_is_normalized() example

<?php
$char_A_ring 
"\xC3\x85"// 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above "\xCC\x8A";  // 'COMBINING RING ABOVE' (U+030A)
 
$char_orig 'A' $char_combining_ring_above;
$char_norm normalizer_normalize'A' $char_combining_ring_aboveNormalizer::FORM_C );
 
echo ( 
normalizer_is_normalized($char_origNormalizer::FORM_C) ) ? "normalized" "not normalized";
echo 
'; ';
echo ( 
normalizer_is_normalized($char_normNormalizer::FORM_C) ) ? "normalized" "not normalized";
?>

Example #2 OO example

<?php
$char_A_ring 
"\xC3\x85"// 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above "\xCC\x8A";  // 'COMBINING RING ABOVE' (U+030A)
 
$char_orig 'A' $char_combining_ring_above;
$char_norm Normalizer::normalize'A' $char_combining_ring_aboveNormalizer::FORM_C );
 
echo ( 
Normalizer::isNormalized($char_origNormalizer::FORM_C) ) ? "normalized" "not normalized";
echo 
'; ';
echo ( 
Normalizer::isNormalized($char_normNormalizer::FORM_C) ) ? "normalized" "not normalized";
?>

The above example will output:

   not normalized; normalized
   

See Also



Normalizer::normalize

normalizer_normalize

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Normalizer::normalize -- normalizer_normalize Normalizes the input provided and returns the normalized string

Description

Object oriented style

public static Normalizer::normalize ( string $input [, int $form = Normalizer::FORM_C ] ) : string

Procedural style

normalizer_normalize ( string $input [, int $form = Normalizer::FORM_C ] ) : string

Normalizes the input provided and returns the normalized string

Parameters

input

The input string to normalize

form

One of the normalization forms.

Return Values

The normalized string or FALSE if an error occurred.

Examples

Example #1 normalizer_normalize() example

<?php
$char_A_ring 
"\xC3\x85"// 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above "\xCC\x8A";  // 'COMBINING RING ABOVE' (U+030A)
 
$char_1 normalizer_normalize$char_A_ringNormalizer::FORM_C );
$char_2 normalizer_normalize'A' $char_combining_ring_aboveNormalizer::FORM_C );
 
echo 
urlencode($char_1);
echo 
' ';
echo 
urlencode($char_2);
?>

Example #2 OO example

<?php
$char_A_ring 
"\xC3\x85"// 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5)
$char_combining_ring_above "\xCC\x8A";  // 'COMBINING RING ABOVE' (U+030A)
 
$char_1 Normalizer::normalize$char_A_ringNormalizer::FORM_C );
$char_2 Normalizer::normalize'A' $char_combining_ring_aboveNormalizer::FORM_C );
 
echo 
urlencode($char_1);
echo 
' ';
echo 
urlencode($char_2);
?>

The above example will output:

   %C3%85 %C3%85
   

See Also


Table of Contents



The MessageFormatter class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

MessageFormatter is a concrete class that enables users to produce concatenated, language-neutral messages. The methods supplied in this class are used to build all the messages that are seen by end users.

The MessageFormatter class assembles messages from various fragments (such as text fragments, numbers, and dates) supplied by the program. Because of the MessageFormatter class, the program does not need to know the order of the fragments. The class uses the formatting specifications for the fragments to assemble them into a message that is contained in a single string within a resource bundle. For example, MessageFormatter enables you to print the phrase "Finished printing x out of y files..." in a manner that still allows for flexibility in translation.

Previously, an end user message was created as a sentence and handled as a string. This procedure created problems for localizers because the sentence structure, word order, number format and so on are very different from language to language. The language-neutral way to create messages keeps each part of the message separate and provides keys to the data. Using these keys, the MessageFormatter class can concatenate the parts of the message, localize them, and display a well-formed string to the end user.

MessageFormatter takes a set of objects, formats them, and then inserts the formatted strings into the pattern at the appropriate places. Choice formats can be used in conjunction with MessageFormatter to handle plurals, match numbers, and select from an array of items. Typically, the message format will come from resources and the arguments will be dynamically set at runtime.

Class synopsis

MessageFormatter {
/* Methods */
public __construct ( string $locale , string $pattern )
public static create ( string $locale , string $pattern ) : MessageFormatter
public static formatMessage ( string $locale , string $pattern , array $args ) : string
public format ( array $args ) : string
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getLocale ( void ) : string
public getPattern ( void ) : string
public static parseMessage ( string $locale , string $pattern , string $source ) : array
public parse ( string $value ) : array
public setPattern ( string $pattern ) : bool
}

MessageFormatter::create

MessageFormatter::__construct

msgfmt_create

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::create -- MessageFormatter::__construct -- msgfmt_createConstructs a new Message Formatter

Description

Object oriented style (method)

public static MessageFormatter::create ( string $locale , string $pattern ) : MessageFormatter

Object oriented style (constructor):

public MessageFormatter::__construct ( string $locale , string $pattern )

Procedural style

msgfmt_create ( string $locale , string $pattern ) : MessageFormatter

Constructs a new Message Formatter

Parameters

locale

The locale to use when formatting arguments

pattern

The pattern string to stick arguments into. The pattern uses an 'apostrophe-friendly' syntax; it is run through » umsg_autoQuoteApostrophe before being interpreted.

Return Values

The formatter object

Errors/Exceptions

When invoked as constructor, on failure an IntlException is thrown.

Examples

Example #1 msgfmt_create() example

<?php
$fmt 
msgfmt_create("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo 
msgfmt_format($fmt, array(45601234560/123));
$fmt msgfmt_create("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo 
msgfmt_format($fmt, array(45601234560/123));
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo 
$fmt->format(array(45601234560/123));
$fmt = new MessageFormatter("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo 
$fmt->format(array(45601234560/123));
?>

The above example will output:

   4,560 monkeys on 123 trees make 37.073 monkeys per tree
   4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
   

See Also



MessageFormatter::formatMessage

msgfmt_format_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::formatMessage -- msgfmt_format_messageQuick format message

Description

Object oriented style

public static MessageFormatter::formatMessage ( string $locale , string $pattern , array $args ) : string

Procedural style

msgfmt_format_message ( string $locale , string $pattern , array $args ) : string

Quick formatting function that formats the string without having to explicitly create the formatter object. Use this function when the format operation is done only once and does not need and parameters or state to be kept.

Parameters

locale

The locale to use for formatting locale-dependent parts

pattern

The pattern string to insert things into. The pattern uses an 'apostrophe-friendly' syntax; it is run through » umsg_autoQuoteApostrophe before being interpreted.

args

The array of values to insert into the format string

Return Values

The formatted pattern string or FALSE if an error occurred

Examples

Example #1 msgfmt_format_message() example

<?php
echo msgfmt_format_message("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree\n", array(45601234560/123));
echo 
msgfmt_format_message("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum\n", array(45601234560/123));
?>

Example #2 OO example

<?php
echo MessageFormatter::formatMessage("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree\n", array(45601234560/123));
echo 
MessageFormatter::formatMessage("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum\n", array(45601234560/123));
?>

The above example will output:

   4,560 monkeys on 123 trees make 37.073 monkeys per tree
   4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
   

See Also



MessageFormatter::format

msgfmt_format

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::format -- msgfmt_formatFormat the message

Description

Object oriented style

public MessageFormatter::format ( array $args ) : string

Procedural style

msgfmt_format ( MessageFormatter $fmt , array $args ) : string

Format the message by substituting the data into the format string according to the locale rules

Parameters

fmt

The message formatter

args

Arguments to insert into the format string

Return Values

The formatted string, or FALSE if an error occurred

Examples

Example #1 msgfmt_format() example

<?php
$fmt 
msgfmt_create("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo 
msgfmt_format($fmt, array(45601234560/123));
$fmt msgfmt_create("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo 
msgfmt_format($fmt, array(45601234560/123));
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter("en_US""{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
echo 
$fmt->format(array(45601234560/123));
$fmt = new MessageFormatter("de""{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
echo 
$fmt->format(array(45601234560/123));
?>

The above example will output:

   4,560 monkeys on 123 trees make 37.073 monkeys per tree
   4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum
   

See Also



MessageFormatter::getErrorCode

msgfmt_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::getErrorCode -- msgfmt_get_error_codeGet the error code from last operation

Description

Object oriented style

public MessageFormatter::getErrorCode ( void ) : int

Procedural style

msgfmt_get_error_code ( MessageFormatter $fmt ) : int

Get the error code from last operation.

Parameters

fmt

The message formatter

Return Values

The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.

See Also



MessageFormatter::getErrorMessage

msgfmt_get_error_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::getErrorMessage -- msgfmt_get_error_messageGet the error text from the last operation

Description

Object oriented style

public MessageFormatter::getErrorMessage ( void ) : string

Procedural style

msgfmt_get_error_message ( MessageFormatter $fmt ) : string

Get the error text from the last operation.

Parameters

fmt

The message formatter

Return Values

Description of the last error.

Examples

Example #1 msgfmt_get_error_message() example

<?php
$fmt 
msgfmt_create("en_US""{0, number} monkeys on {1, number} trees");
$str msgfmt_format($fmt, array());
if(!
$str) {
    echo 
"ERROR: ".msgfmt_get_error_message($fmt) . " (" msgfmt_get_error_code($fmt) . ")\n";
}
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter("en_US""{0, number} monkeys on {1, number} trees");
$str $fmt->format(array());
if(!
$str) {
    echo 
"ERROR: ".$fmt->getErrorMessage() . " (" $fmt->getErrorCode() . ")\n";
}
?>

The above example will output:

   ERROR: msgfmt_format: not enough parameters: U_ILLEGAL_ARGUMENT_ERROR (1)
   

See Also



MessageFormatter::getLocale

msgfmt_get_locale

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::getLocale -- msgfmt_get_localeGet the locale for which the formatter was created

Description

Object oriented style

public MessageFormatter::getLocale ( void ) : string

Procedural style

msgfmt_get_locale ( NumberFormatter $formatter ) : string

Get the locale for which the formatter was created.

Parameters

formatter

The formatter resource

Return Values

The locale name

Examples

Example #1 msgfmt_get_locale() example

<?php
$fmt 
msgfmt_create('en_US'"Number {0,number}");
echo 
msgfmt_get_locale($fmt);
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter('en_US'"Number {0,number}");
echo 
$fmt->getLocale();
?>

The above example will output:

   en_US
   

See Also



MessageFormatter::getPattern

msgfmt_get_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::getPattern -- msgfmt_get_patternGet the pattern used by the formatter

Description

Object oriented style

public MessageFormatter::getPattern ( void ) : string

Procedural style

msgfmt_get_pattern ( MessageFormatter $fmt ) : string

Get the pattern used by the formatter

Parameters

fmt

The message formatter

Return Values

The pattern string for this message formatter

Examples

Example #1 msgfmt_get_pattern() example

<?php
$fmt 
msgfmt_create"en_US""{0, number} monkeys on {1, number} trees" );
echo 
"Default pattern: '" msgfmt_get_pattern$fmt ) . "'\n";
echo 
"Formatting result: " msgfmt_format$fmt, array(123456) ) . "\n";

msgfmt_set_pattern$fmt"{0, number} trees hosting {1, number} monkeys" );
echo 
"New pattern: '" msgfmt_get_pattern$fmt ) . "'\n";
echo 
"Formatted number: " msgfmt_format$fmt, array(123456) ) . "\n";
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter"en_US""{0, number} monkeys on {1, number} trees" );
echo 
"Default pattern: '" $fmt->getPattern() . "'\n";
echo 
"Formatting result: " $fmt->format(array(123456)) . "\n";

$fmt->setPattern("{0, number} trees hosting {1, number} monkeys" );
echo 
"New pattern: '" $fmt->getPattern() . "'\n";
echo 
"Formatted number: " $fmt->format(array(123456)) . "\n";
?>

The above example will output:

   Default pattern: '{0,number} monkeys on {1,number} trees'
   Formatting result: 123 monkeys on 456 trees
   New pattern: '{0,number} trees hosting {1,number} monkeys'
   Formatted number: 123 trees hosting 456 monkeys
   

See Also



MessageFormatter::parseMessage

msgfmt_parse_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::parseMessage -- msgfmt_parse_messageQuick parse input string

Description

Object oriented style

public static MessageFormatter::parseMessage ( string $locale , string $pattern , string $source ) : array

Procedural style

msgfmt_parse_message ( string $locale , string $pattern , string $value ) : array

Parses input string without explicitly creating the formatter object. Use this function when the format operation is done only once and does not need and parameters or state to be kept.

Parameters

locale

The locale to use for parsing locale-dependent parts

pattern

The pattern with which to parse the value.

source

The string to parse, conforming to the pattern.

Return Values

An array containing items extracted, or FALSE on error

Examples

Example #1 msgfmt_parse_message() example

<?php
$fmt 
msgfmt_parse_message('en_US'"{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
                            
"4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($fmt);

$fmt msgfmt_parse_message('de'"{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum"
                            
"4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($fmt);
?>

Example #2 OO example

<?php
$fmt 
MessageFormatter::parseMessage('en_US'"{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree",
                            
"4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($fmt);

$fmt MessageFormatter::parseMessage('de'"{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum"
                            
"4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($fmt);
?>

The above example will output:

   array (
     0 => 4560,
     1 => 123,
     2 => 37.073,
   )
   array (
     0 => 4560,
     1 => 123,
     2 => 37.073,
   )
   

See Also



MessageFormatter::parse

msgfmt_parse

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::parse -- msgfmt_parseParse input string according to pattern

Description

Object oriented style

public MessageFormatter::parse ( string $value ) : array

Procedural style

msgfmt_parse ( MessageFormatter $fmt , string $value ) : array

Parses input string and return any extracted items as an array.

Parameters

fmt

The message formatter

value

The string to parse

Return Values

An array containing the items extracted, or FALSE on error

Examples

Example #1 msgfmt_parse() example

<?php
$fmt 
msgfmt_create('en_US'"{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
$res msgfmt_parse($fmt"4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($res);

$fmt msgfmt_create('de'"{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
$res msgfmt_parse($fmt"4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($res);
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter('en_US'"{0,number,integer} monkeys on {1,number,integer} trees make {2,number} monkeys per tree");
$res $fmt->parse("4,560 monkeys on 123 trees make 37.073 monkeys per tree");
var_export($res);

$fmt = new MessageFormatter('de'"{0,number,integer} Affen auf {1,number,integer} Bäumen sind {2,number} Affen pro Baum");
$res $fmt->parse("4.560 Affen auf 123 Bäumen sind 37,073 Affen pro Baum");
var_export($res);
?>

The above example will output:

   array (
     0 => 4560,
     1 => 123,
     2 => 37.073,
   )
   array (
     0 => 4560,
     1 => 123,
     2 => 37.073,
   )
   

See Also



MessageFormatter::setPattern

msgfmt_set_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

MessageFormatter::setPattern -- msgfmt_set_patternSet the pattern used by the formatter

Description

Object oriented style

public MessageFormatter::setPattern ( string $pattern ) : bool

Procedural style

msgfmt_set_pattern ( MessageFormatter $fmt , string $pattern ) : bool

Set the pattern used by the formatter

Parameters

fmt

The message formatter

pattern

The pattern string to use in this message formatter. The pattern uses an 'apostrophe-friendly' syntax; it is run through » umsg_autoQuoteApostrophe before being interpreted.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 msgfmt_set_pattern() example

<?php
$fmt 
msgfmt_create"en_US""{0, number} monkeys on {1, number} trees" );
echo 
"Default pattern: '" msgfmt_get_pattern$fmt ) . "'\n";
echo 
"Formatting result: " msgfmt_format$fmt, array(123456) ) . "\n";

msgfmt_set_pattern$fmt"{0, number} trees hosting {1, number} monkeys" );
echo 
"New pattern: '" msgfmt_get_pattern$fmt ) . "'\n";
echo 
"Formatted number: " msgfmt_format$fmt, array(123456) ) . "\n";
?>

Example #2 OO example

<?php
$fmt 
= new MessageFormatter"en_US""{0, number} monkeys on {1, number} trees" );
echo 
"Default pattern: '" $fmt->getPattern() . "'\n";
echo 
"Formatting result: " $fmt->format(array(123456)) . "\n";

$fmt->setPattern("{0, number} trees hosting {1, number} monkeys" );
echo 
"New pattern: '" $fmt->getPattern() . "'\n";
echo 
"Formatted number: " $fmt->format(array(123456)) . "\n";
?>

The above example will output:

   Default pattern: '{0,number} monkeys on {1,number} trees'
   Formatting result: 123 monkeys on 456 trees
   New pattern: '{0,number} trees hosting {1,number} monkeys'
   Formatted number: 123 trees hosting 456 monkeys
   

See Also


Table of Contents



The IntlCalendar class

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

Introduction

Class synopsis

IntlCalendar {
/* Constants */
const integer FIELD_ERA = 0 ;
const integer FIELD_YEAR = 1 ;
const integer FIELD_MONTH = 2 ;
const integer FIELD_WEEK_OF_YEAR = 3 ;
const integer FIELD_WEEK_OF_MONTH = 4 ;
const integer FIELD_DATE = 5 ;
const integer FIELD_DAY_OF_YEAR = 6 ;
const integer FIELD_DAY_OF_WEEK = 7 ;
const integer FIELD_DAY_OF_WEEK_IN_MONTH = 8 ;
const integer FIELD_AM_PM = 9 ;
const integer FIELD_HOUR = 10 ;
const integer FIELD_HOUR_OF_DAY = 11 ;
const integer FIELD_MINUTE = 12 ;
const integer FIELD_SECOND = 13 ;
const integer FIELD_MILLISECOND = 14 ;
const integer FIELD_ZONE_OFFSET = 15 ;
const integer FIELD_DST_OFFSET = 16 ;
const integer FIELD_YEAR_WOY = 17 ;
const integer FIELD_DOW_LOCAL = 18 ;
const integer FIELD_EXTENDED_YEAR = 19 ;
const integer FIELD_JULIAN_DAY = 20 ;
const integer FIELD_MILLISECONDS_IN_DAY = 21 ;
const integer FIELD_IS_LEAP_MONTH = 22 ;
const integer FIELD_FIELD_COUNT = 23 ;
const integer FIELD_DAY_OF_MONTH = 5 ;
const integer DOW_SUNDAY = 1 ;
const integer DOW_MONDAY = 2 ;
const integer DOW_TUESDAY = 3 ;
const integer DOW_WEDNESDAY = 4 ;
const integer DOW_THURSDAY = 5 ;
const integer DOW_FRIDAY = 6 ;
const integer DOW_SATURDAY = 7 ;
const integer DOW_TYPE_WEEKDAY = 0 ;
const integer DOW_TYPE_WEEKEND = 1 ;
const integer DOW_TYPE_WEEKEND_OFFSET = 2 ;
const integer DOW_TYPE_WEEKEND_CEASE = 3 ;
const integer WALLTIME_FIRST = 1 ;
const integer WALLTIME_LAST = 0 ;
const integer WALLTIME_NEXT_VALID = 2 ;
/* Methods */
public add ( int $field , int $amount ) : bool
intlcal_add ( IntlCalendar $cal , int $field , int $amount ) : bool
public after ( IntlCalendar $other ) : bool
intlcal_after ( IntlCalendar $cal , IntlCalendar $other ) : bool
public before ( IntlCalendar $other ) : bool
intlcal_before ( IntlCalendar $cal , IntlCalendar $other ) : bool
public clear ([ int $field = NULL ] ) : bool
intlcal_clear ( IntlCalendar $cal [, int $field = NULL ] ) : bool
private __construct ( void )
public static createInstance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar
intlcal_create_instance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar
public equals ( IntlCalendar $other ) : bool
intlcal_equals ( IntlCalendar $cal , IntlCalendar $other ) : bool
public fieldDifference ( float $when , int $field ) : int
intlcal_field_difference ( IntlCalendar $cal , float $when , int $field ) : int
public static fromDateTime ( mixed $dateTime ) : IntlCalendar
intlcal_from_date_time ( mixed $dateTime ) : IntlCalendar
public get ( int $field ) : int
intlcal_get ( IntlCalendar $cal , int $field ) : int
public getActualMaximum ( int $field ) : int
intlcal_get_actual_maximum ( IntlCalendar $cal , int $field ) : int
public getActualMinimum ( int $field ) : int
intlcal_get_actual_minimum ( IntlCalendar $cal , int $field ) : int
public static getAvailableLocales ( void ) : array
intlcal_get_available_locales ( void ) : array
public getDayOfWeekType ( int $dayOfWeek ) : int
intlcal_get_day_of_week_type ( IntlCalendar $cal , int $dayOfWeek ) : int
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getFirstDayOfWeek ( void ) : int
intlcal_get_first_day_of_week ( IntlCalendar $cal ) : int
public getGreatestMinimum ( int $field ) : int
intlcal_get_greatest_minimum ( IntlCalendar $cal , int $field ) : int
public static getKeywordValuesForLocale ( string $key , string $locale , bool $commonlyUsed ) : Iterator
intlcal_get_keyword_values_for_locale ( string $key , string $locale , bool $commonlyUsed ) : Iterator
public getLeastMaximum ( int $field ) : int
intlcal_get_least_maximum ( IntlCalendar $cal , int $field ) : int
public getLocale ( int $localeType ) : string
intlcal_get_locale ( IntlCalendar $cal , int $localeType ) : string
public getMaximum ( int $field ) : int
intlcal_get_maximum ( IntlCalendar $cal , int $field ) : int
public getMinimalDaysInFirstWeek ( void ) : int
intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal ) : int
public getMinimum ( int $field ) : int
intlcal_get_minimum ( IntlCalendar $cal , int $field ) : int
public static getNow ( void ) : float
intlcal_get_now ( void ) : float
public getRepeatedWallTimeOption ( void ) : int
intlcal_get_repeated_wall_time_option ( IntlCalendar $cal ) : int
public getSkippedWallTimeOption ( void ) : int
intlcal_get_skipped_wall_time_option ( IntlCalendar $cal ) : int
public getTime ( void ) : float
intlcal_get_time ( IntlCalendar $cal ) : float
public getTimeZone ( void ) : IntlTimeZone
intlcal_get_time_zone ( IntlCalendar $cal ) : IntlTimeZone
public getType ( void ) : string
intlcal_get_type ( IntlCalendar $cal ) : string
public getWeekendTransition ( string $dayOfWeek ) : int
intlcal_get_weekend_transition ( IntlCalendar $cal , string $dayOfWeek ) : int
public inDaylightTime ( void ) : bool
intlcal_in_daylight_time ( IntlCalendar $cal ) : bool
public isEquivalentTo ( IntlCalendar $other ) : bool
intlcal_is_equivalent_to ( IntlCalendar $cal , IntlCalendar $other ) : bool
public isLenient ( void ) : bool
intlcal_is_lenient ( IntlCalendar $cal ) : bool
public isSet ( int $field ) : bool
intlcal_is_set ( IntlCalendar $cal , int $field ) : bool
public isWeekend ([ float $date = NULL ] ) : bool
intlcal_is_weekend ( IntlCalendar $cal [, float $date = NULL ] ) : bool
public roll ( int $field , mixed $amountOrUpOrDown ) : bool
intlcal_roll ( IntlCalendar $cal , int $field , mixed $amountOrUpOrDown ) : bool
public set ( int $field , int $value ) : bool
public set ( int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool
intlcal_set ( IntlCalendar $cal , int $field , int $value ) : bool
intlcal_set ( IntlCalendar $cal , int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool
public setFirstDayOfWeek ( int $dayOfWeek ) : bool
intlcal_set_first_day_of_week ( IntlCalendar $cal , int $dayOfWeek ) : bool
public setLenient ( bool $isLenient ) : bool
intlcal_set_lenient ( IntlCalendar $cal , bool $isLenient ) : bool
public setMinimalDaysInFirstWeek ( int $minimalDays ) : bool
intlcal_set_minimal_days_in_first_week ( IntlCalendar $cal , int $minimalDays ) : bool
public setRepeatedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_repeated_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public setSkippedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_skipped_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public setTime ( float $date ) : bool
intlcal_set_time ( IntlCalendar $cal , float $date ) : bool
public setTimeZone ( mixed $timeZone ) : bool
intlcal_set_time_zone ( IntlCalendar $cal , mixed $timeZone ) : bool
public toDateTime ( void ) : DateTime
intlcal_to_date_time ( IntlCalendar $cal ) : DateTime
}

Predefined Constants

IntlCalendar::FIELD_ERA

Calendar field numerically representing an era, for instance 1 for AD and 0 for BC in the Gregorian/Julian calendars and 235 for the Heisei (平成) era in the Japanese calendar. Not all calendars have more than one era.

IntlCalendar::FIELD_YEAR

Calendar field for the year. This is not unique across eras. If the calendar type has more than one era, generally the minimum value for this field will be 1.

IntlCalendar::FIELD_MONTH

Calendar field for the month. The month sequence is zero-based, so January (here used to signify the first month of the calendar; this may be called another name, such as Muharram in the Islamic calendar) is represented by 0, February by 1, …, December by 11 and, for calendars that have it, the 13th or leap month by 12.

IntlCalendar::FIELD_WEEK_OF_YEAR

Calendar field for the number of the week of the year. This depends on which day of the week is deemed to start the week and the minimal number of days in a week.

IntlCalendar::FIELD_WEEK_OF_MONTH

Calendar field for the number of the week of the month. This depends on which day of the week is deemed to start the week and the minimal number of days in a week.

IntlCalendar::FIELD_DATE

Calendar field for the day of the month. The same as IntlCalendar::FIELD_DAY_OF_MONTH, which has a clearer name.

IntlCalendar::FIELD_DAY_OF_YEAR

Calendar field for the day of the year. For the Gregorian calendar, starts with 1 and ends with 365 or 366.

IntlCalendar::FIELD_DAY_OF_WEEK

Calendar field for the day of the week. Its values start with 1 (Sunday, see IntlCalendar::DOW_SUNDAY and subsequent constants) and the last valid value is 7 (Saturday).

IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH

Given a day of the week (Sunday, Monday, …), this calendar field assigns an ordinal to such a day of the week in a specific month. Thus, if the value of this field is 1 and the value of the day of the week is 2 (Monday), then the set day of the month is the 1st Monday of the month; the maximum value is 5.

Additionally, the value 0 and negative values are also allowed. The value 0 encompasses the seven days that occur immediately before the first seven days of a month (which therefore have a ‘day of week in month’ with value 1). Negative values starts counting from the end of the month – -1 points to the last occurrence of a day of the week in a month, -2 to the second last, and so on.

Unlike IntlCalendar::FIELD_WEEK_OF_MONTH and IntlCalendar::FIELD_WEEK_OF_YEAR, this value does not depend on IntlCalendar::getFirstDayOfWeek() or on IntlCalendar::getMinimalDaysInFirstWeek(). The first Monday is the first Monday, even if it occurs in a week that belongs to the previous month.

IntlCalendar::FIELD_AM_PM

Calendar field indicating whether a time is before noon (value 0, AM) or after (1). Midnight is AM, noon is PM.

IntlCalendar::FIELD_HOUR

Calendar field for the hour, without specifying whether itʼs in the morning or in the afternoon. Valid values are 0 to 11.

IntlCalendar::FIELD_HOUR_OF_DAY

Calendar field for the full (24h) hour of the day. Valid values are 0 to 23.

IntlCalendar::FIELD_MINUTE

Calendar field for the minutes component of the time.

IntlCalendar::FIELD_SECOND

Calendar field for the seconds component of the time.

IntlCalendar::FIELD_MILLISECOND

Calendar field the milliseconds component of the time.

IntlCalendar::FIELD_ZONE_OFFSET

Calendar field indicating the raw offset of the timezone, in milliseconds. The raw offset is the timezone offset, excluding any offset due to daylight saving time.

IntlCalendar::FIELD_DST_OFFSET

Calendar field for the daylight saving time offset of the calendarʼs timezone, in milliseconds, if active for calendarʼs time.

IntlCalendar::FIELD_YEAR_WOY

Calendar field representing the year for week of year purposes.

IntlCalendar::FIELD_DOW_LOCAL

Calendar field for the localized day of the week. This is a value between 1 and 7, 1 being used for the day of the week that matches the value returned by IntlCalendar::getFirstDayOfWeek().

IntlCalendar::FIELD_EXTENDED_YEAR

Calendar field for a year number representation that is continuous across eras. For the Gregorian calendar, the value of this field matches that of IntlCalendar::FIELD_YEAR for AD years; a BC year y is represented by -y + 1.

IntlCalendar::FIELD_JULIAN_DAY

Calendar field for a modified Julian day number. It is different from a conventional Julian day number in that its transitions occur at local zone midnight rather than at noon UTC. It uniquely identifies a date.

IntlCalendar::FIELD_MILLISECONDS_IN_DAY

Calendar field encompassing the information in IntlCalendar::FIELD_HOUR_OF_DAY, IntlCalendar::FIELD_MINUTE, IntlCalendar::FIELD_SECOND and IntlCalendar::FIELD_MILLISECOND. Range is from the 0 to 24 * 3600 * 1000 - 1. It is not the amount of milliseconds elapsed in the day since on DST transitions it will have discontinuities analog to those of the wall time.

IntlCalendar::FIELD_IS_LEAP_MONTH

Calendar field whose value is 1 for indicating a leap month and 0 otherwise.

IntlCalendar::FIELD_FIELD_COUNT

The total number of fields.

IntlCalendar::FIELD_DAY_OF_MONTH

Alias for IntlCalendar::FIELD_DATE.

IntlCalendar::DOW_SUNDAY

Sunday.

IntlCalendar::DOW_MONDAY

Monday.

IntlCalendar::DOW_TUESDAY

Tuesday.

IntlCalendar::DOW_WEDNESDAY

Wednesday.

IntlCalendar::DOW_THURSDAY

Thursday.

IntlCalendar::DOW_FRIDAY

Friday.

IntlCalendar::DOW_SATURDAY

Saturday.

IntlCalendar::DOW_TYPE_WEEKDAY

Output of IntlCalendar::getDayOfWeekType() indicating a day of week is a weekday.

IntlCalendar::DOW_TYPE_WEEKEND

Output of IntlCalendar::getDayOfWeekType() indicating a day of week belongs to the weekend.

IntlCalendar::DOW_TYPE_WEEKEND_OFFSET

Output of IntlCalendar::getDayOfWeekType() indicating the weekend begins during the given day of week.

IntlCalendar::DOW_TYPE_WEEKEND_CEASE

Output of IntlCalendar::getDayOfWeekType() indicating the weekend ends during the given day of week.

IntlCalendar::WALLTIME_FIRST

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the same instant as wall times with one hour less and of IntlCalendar::getRepeatedWallTimeOption() indicating the wall times in the repeated range should refer to the instant of the first occurrence of such wall time.

IntlCalendar::WALLTIME_LAST

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the same instant as wall times with one hour after and of IntlCalendar::getRepeatedWallTimeOption() indicating the wall times in the repeated range should refer to the instant of the second occurrence of such wall time.

IntlCalendar::WALLTIME_NEXT_VALID

Output of IntlCalendar::getSkippedWallTimeOption() indicating that wall times in the skipped range should refer to the instant when the daylight saving time transition occurs (begins).


IntlCalendar::add

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::addAdd a (signed) amount of time to a field

Description

Object oriented style

public IntlCalendar::add ( int $field , int $amount ) : bool

Procedural style

intlcal_add ( IntlCalendar $cal , int $field , int $amount ) : bool

Add a signed amount to a field. Adding a positive amount allows advances in time, even if the numeric value of the field decreases (e.g. when working with years in BC dates).

Other fields may need to adjusted – for instance, adding a month to the 31st of January will result in the 28th (or 29th) of February. Contrary to IntlCalendar::roll(), when a value wraps around, more significant fields may change. For instance, adding a day to the 31st of January will result in the 1st of February, not the 1st of January.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

amount

The signed amount to add to the current field. If the amount is positive, the instant will be moved forward; if it is negative, the instant will be moved into the past. The unit is implicit to the field type. For instance, hours for IntlCalendar::FIELD_HOUR_OF_DAY.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 IntlCalendar::add()

<?php
ini_set
('intl.default_locale''fr_FR');
ini_set('date.timezone''UTC');

$cal = new IntlGregorianCalendar(2012/* January */31);
echo 
IntlDateFormatter::formatObject($cal), "\n";

$cal->add(IntlCalendar::FIELD_MONTH1);
echo 
IntlDateFormatter::formatObject($cal), "\n";

$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH1);
echo 
IntlDateFormatter::formatObject($cal), "\n";

The above example will output:

   31 janv. 2012 00:00:00
   29 févr. 2012 00:00:00
   1 mars 2012 00:00:00
   



IntlCalendar::after

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::afterWhether this objectʼs time is after that of the passed object

Description

Object oriented style

public IntlCalendar::after ( IntlCalendar $other ) : bool

Procedural style

intlcal_after ( IntlCalendar $cal , IntlCalendar $other ) : bool

Returns whether this objectʼs time succeeds the argumentʼs time.

Parameters

cal

The IntlCalendar resource.

other

The calendar whose time will be checked against the primary objectʼs time.

Return Values

Returns TRUE if this objectʼs current time is after that of the calendar argumentʼs time. Returns FALSE otherwise. Also returns FALSE on failure. You can use exceptions or intl_get_error_code() to detect error conditions.

Examples

Example #1 IntlCalendar::after()

<?php
$cal1 
IntlCalendar::createInstance();
$cal2 = clone $cal1;

var_dump($cal1->after($cal2), //false
        
$cal2->after($cal1)); //false

$cal1->roll(IntlCalendar::FIELD_MILLISECONDtrue);

var_dump($cal1->after($cal2), //true
        
$cal2->after($cal1)); //false



IntlCalendar::before

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::beforeWhether this objectʼs time is before that of the passed object

Description

Object oriented style

public IntlCalendar::before ( IntlCalendar $other ) : bool

Procedural style

intlcal_before ( IntlCalendar $cal , IntlCalendar $other ) : bool

Returns whether this objectʼs time precedes the argumentʼs time.

Parameters

cal

The IntlCalendar resource.

other

The calendar whose time will be checked against the primary objectʼs time.

Return Values

Returns TRUE if this objectʼs current time is before that of the calendar argumentʼs time. Returns FALSE otherwise. Also returns FALSE on failure. You can use exceptions or intl_get_error_code() to detect error conditions.



IntlCalendar::clear

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::clearClear a field or all fields

Description

Object oriented style

public IntlCalendar::clear ([ int $field = NULL ] ) : bool

Procedural style

intlcal_clear ( IntlCalendar $cal [, int $field = NULL ] ) : bool

Clears either all of the fields or a specific field. A cleared field is marked as unset, giving it the lowest priority against overlapping fields or even default values when calculating the time. Additionally, its value is set to 0, though given the fieldʼs low priority, its value may have been internally set to another value by the time the field has finished been queried.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

Returns TRUE on success or FALSE on failure. Failure can only occur is invalid arguments are provided.

Examples

Example #1 IntlCalendar::clear() examples

<?php
ini_set
('intl.default_locale''es_ES');
ini_set('date.timezone''UTC');

$fields = array(
    
'FIELD_ERA'                  => 0,
    
'FIELD_YEAR'                 => 1,
    
'FIELD_MONTH'                => 2,
    
'FIELD_WEEK_OF_YEAR'         => 3,
    
'FIELD_WEEK_OF_MONTH'        => 4,
    
'FIELD_DATE'                 => 5,
    
'FIELD_DAY_OF_YEAR'          => 6,
    
'FIELD_DAY_OF_WEEK'          => 7,
    
'FIELD_DAY_OF_WEEK_IN_MONTH' => 8,
    
'FIELD_AM_PM'                => 9,
    
'FIELD_HOUR'                 => 10,
    
'FIELD_HOUR_OF_DAY'          => 11,
    
'FIELD_MINUTE'               => 12,
    
'FIELD_SECOND'               => 13,
    
'FIELD_MILLISECOND'          => 14,
    
'FIELD_ZONE_OFFSET'          => 15,
    
'FIELD_DST_OFFSET'           => 16,
    
'FIELD_YEAR_WOY'             => 17,
    
'FIELD_DOW_LOCAL'            => 18,
    
'FIELD_EXTENDED_YEAR'        => 19,
    
'FIELD_JULIAN_DAY'           => 20,
    
'FIELD_MILLISECONDS_IN_DAY'  => 21,
    
'FIELD_IS_LEAP_MONTH'        => 22,
    
'FIELD_FIELD_COUNT'          => 23,
);
function 
getSetFields(IntlCalendar $cal) {
    global 
$fields;
    
$ret = array();
    foreach (
$fields as $name => $value) {
        if (
$cal->isSet($value)) {
            
$ret[] = $name;
        }
    }
    return 
$ret;
}

$cal = new IntlGregorianCalendar(2013/* March */15);
echo 
"After GregorianCalendar creation\n";
print_r(getSetFields($cal));
echo 
"\n";

echo 
IntlDateFormatter::formatObject($cal), "\n";
echo 
"After the formatter requested the extended year\n";
print_r(getSetFields($cal));
echo 
"\n";

$cal->clear(IntlCalendar::FIELD_YEAR);
echo 
"After the year has been cleared, the date stays the same\n";
echo 
IntlDateFormatter::formatObject($cal), "\n";
echo 
"because FIELD_EXTENDED_YEAR is still set\n";
print_r(getSetFields($cal));
echo 
"\n";

var_dump($cal->clear(IntlCalendar::FIELD_EXTENDED_YEAR));
echo 
"After the extended year has been cleared\n";
print_r(getSetFields($cal));
echo 
IntlDateFormatter::formatObject($cal), "\n";
echo 
"\n";

echo 
"After the fields are recalculated,\n"
        
" extended year is set again (to 1970)\n";
print_r(getSetFields($cal));
echo 
"\n";

$cal->clear();
echo 
"After calling variant with no arguments\n";
print_r(getSetFields($cal));
echo 
IntlDateFormatter::formatObject($cal), "\n";

The above example will output:

   After GregorianCalendar creation
   Array
   (
       [0] => FIELD_ERA
       [1] => FIELD_YEAR
       [2] => FIELD_MONTH
       [3] => FIELD_DATE
   )
   
   15/03/2013 00:00:00
   After the formatter requested the extended year
   Array
   (
       [0] => FIELD_ERA
       [1] => FIELD_YEAR
       [2] => FIELD_MONTH
       [3] => FIELD_DATE
       [4] => FIELD_EXTENDED_YEAR
   )
   
   After the year has been cleared, the date stays the same
   15/03/2013 00:00:00
   because FIELD_EXTENDED_YEAR is still set
   Array
   (
       [0] => FIELD_ERA
       [1] => FIELD_MONTH
       [2] => FIELD_DATE
       [3] => FIELD_EXTENDED_YEAR
   )
   
   bool(true)
   After the extended year has been cleared
   Array
   (
       [0] => FIELD_ERA
       [1] => FIELD_MONTH
       [2] => FIELD_DATE
   )
   15/03/1970 00:00:00
   
   After the fields are recalculated,
    extended year is set again (to 1970)
   Array
   (
       [0] => FIELD_ERA
       [1] => FIELD_MONTH
       [2] => FIELD_DATE
       [3] => FIELD_EXTENDED_YEAR
   )
   
   After calling variant with no arguments
   Array
   (
   )
   01/01/1970 00:00:00
   
   



IntlCalendar::__construct

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::__constructPrivate constructor for disallowing instantiation

Description

private IntlCalendar::__construct ( void )

A private constructor for disallowing instantiation with the new operator.

Call IntlCalendar::createInstance() instead.

Parameters

This function has no parameters.

Return Values

No value is returned.



IntlCalendar::createInstance

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::createInstanceCreate a new IntlCalendar

Description

Object oriented style

public static IntlCalendar::createInstance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar

Procedural style

intlcal_create_instance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar

Given a timezone and locale, this method creates an IntlCalendar object. This factory method may return a subclass of IntlCalendar.

The calendar created will represent the time instance at which it was created, based on the system time. The fields can all be cleared by calling IntCalendar::clear() with no arguments. See also IntlGregorianCalendar::__construct().

Parameters

timeZone

The timezone to use.

locale

A locale to use or NULL to use the default locale.

Return Values

The created IntlCalendar instance or NULL on failure.

Examples

Example #1 IntlCalendar::createInstance()

<?php
ini_set
('intl.default_locale''es_ES');
ini_set('date.timezone''Europe/Madrid');

$cal IntlCalendar::createInstance();
echo 
"No arguments\n";
var_dump(get_class($cal),
        
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL));
echo 
"\n";

echo 
"Explicit timezone\n";
$cal IntlCalendar::createInstance(IntlTimeZone::getGMT());
var_dump(get_class($cal),
        
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL));
echo 
"\n";

echo 
"Explicit locale (with calendar)\n";
$cal IntlCalendar::createInstance(NULL'es_ES@calendar=persian');
var_dump(get_class($cal),
        
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL));

The above example will output:

   No arguments
   string(21) "IntlGregorianCalendar"
   string(68) "martes 18 de junio de 2013 14:11:02 Hora de verano de Europa Central"
   
   Explicit timezone
   string(21) "IntlGregorianCalendar"
   string(45) "martes 18 de junio de 2013 12:11:02 GMT+00:00"
   
   Explicit locale (with calendar)
   string(12) "IntlCalendar"
   string(70) "martes 28 de Khordad de 1392 14:11:02 Hora de verano de Europa Central"
   
   

See Also



IntlCalendar::equals

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::equalsCompare time of two IntlCalendar objects for equality

Description

Object oriented style

public IntlCalendar::equals ( IntlCalendar $other ) : bool

Procedural style

intlcal_equals ( IntlCalendar $cal , IntlCalendar $other ) : bool

Returns true if this calendar and the given calendar have the same time. The settings, calendar types and field states do not have to be the same.

Parameters

cal

The IntlCalendar resource.

other

The calendar to compare with the primary object.

Return Values

Returns TRUE if the current time of both this and the passed in IntlCalendar object are the same, or FALSE otherwise. The value FALSE can also be returned on failure. This can only happen if bad arguments are passed in. In any case, the two cases can be distinguished by calling intl_get_error_code().

Examples

Example #1 IntlCalendar::equals()

<?php
ini_set
('date.timezone''UTC');

$cal1 IntlCalendar::createInstance(NULL'es_ES');
$cal2 = clone $cal1;

var_dump($cal1->equals($cal2)); //TRUE

//The locale is not included in the comparison
$cal2 IntlCalendar::createInstance(NULL'pt_PT');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE

//And set fields state is not included as well
$cal2->clear(IntlCalendar::FIELD_YEAR);
var_dump($cal1->isSet(IntlCalendar::FIELD_YEAR) ==
        
$cal2->isSet(IntlCalendar::FIELD_YEAR)); //FALSE
var_dump($cal1->equals($cal2)); //TRUE

//Neither is the calendar type
$cal2 IntlCalendar::createInstance(NULL'es_ES@calendar=islamic');
$cal2->setTime($cal1->getTime());
var_dump($cal1->equals($cal2)); //TRUE

//Only the time is
$cal2 = clone $cal1;
$cal2->setTime($cal1->getTime() + 1.);
var_dump($cal1->equals($cal2)); //FALSE



IntlCalendar::fieldDifference

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::fieldDifferenceCalculate difference between given time and this objectʼs time

Description

Object oriented style

public IntlCalendar::fieldDifference ( float $when , int $field ) : int

Procedural style

intlcal_field_difference ( IntlCalendar $cal , float $when , int $field ) : int

Return the difference between the given time and the time this object is set to, with respect to the quantity specified the field parameter.

This method is meant to be called successively, first with the most significant field of interest down to the least significant field. To this end, as a side effect, this calendarʼs value for the field specified is advanced by the amount returned.

Parameters

cal

The IntlCalendar resource.

when

The time against which to compare the quantity represented by the field. For the result to be positive, the time given for this parameter must be ahead of the time of the object the method is being invoked on.

field

The field that represents the quantity being compared.

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

Returns a (signed) difference of time in the unit associated with the specified field or FALSE on failure.

Examples

Example #1 IntlCalendar::fieldDifference()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''fr_FR');

$cal1 IntlCalendar::fromDateTime('2012-02-29 09:00:11');
$cal2 IntlCalendar::fromDateTime('2013-03-01 09:19:29');
$time $cal2->getTime();

echo 
"Time before: "IntlDateFormatter::formatObject($cal1), "\n";

printf(
    
"The difference in time is %d year(s), %d month(s), "
  
"%d day(s), %d hour(s) and %d minute(s)\n",
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_YEAR),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_MONTH),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_DAY_OF_MONTH),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_HOUR_OF_DAY),
    
$cal1->fieldDifference($timeIntlCalendar::FIELD_MINUTE)
);

//now it was advanced to the target time, exception for the seconds,
//for which we did not measure the difference
echo "Time after: "IntlDateFormatter::formatObject($cal1), "\n";

The above example will output:

   Time before: 29 févr. 2012 09:00:11
   The difference in time is 1 year(s), 0 month(s), 1 day(s), 0 hour(s) and 19 minute(s)
   Time after: 1 mars 2013 09:19:11
   



IntlCalendar::fromDateTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a2)

IntlCalendar::fromDateTimeCreate an IntlCalendar from a DateTime object or string

Description

Object oriented style

public static IntlCalendar::fromDateTime ( mixed $dateTime ) : IntlCalendar

Procedural style

intlcal_from_date_time ( mixed $dateTime ) : IntlCalendar

Creates an IntlCalendar object either from a DateTime object or from a string from which a DateTime object can be built.

The new calendar will represent not only the same instant as the given DateTime (subject to precision loss for dates very far into the past or future), but also the same timezone (subject to the caveat that different timezone databases will be used, and therefore the results may differ).

Parameters

dateTime

A DateTime object or a string that can be passed to DateTime::__construct().

Return Values

The created IntlCalendar object or NULL in case of failure. If a string is passed, any exception that occurs inside the DateTime constructor is propagated.

Examples

Example #1 IntlCalendar::fromDateTime()

<?php
ini_set
('date.timezone''Europe/Lisbon');

//same as IntlCalendar::fromDateTime(new DateTime(...))
$cal1 IntlCalendar::fromDateTime('2013-02-28 00:01:02 Europe/Berlin');

//Note the timezone is Europe/Berlin, not the default Europe/Lisbon
echo IntlDateFormatter::formatObject($cal1'yyyy MMMM d HH:mm:ss VVVV''de_DE'), "\n";

The above example will output:

   2013 Februar 28 00:01:02 Deutschland Zeit
   



IntlCalendar::get

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getGet the value for a field

Description

Object oriented style

public IntlCalendar::get ( int $field ) : int

Procedural style

intlcal_get ( IntlCalendar $cal , int $field ) : int

Gets the value for a specific field.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An integer with the value of the time field.

Examples

Example #1 IntlCalendar::get()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');

$class = new ReflectionClass('IntlCalendar');
$fields = array();
foreach (
$class->getConstants() as $name => $val) {
    if (
strpos($name'FIELD_') !== || $val 22)
        continue;
    
$fields[$val] = $name;
}

$cal IntlCalendar::createInstance(); // current time
var_dump(IntlDateFormatter::formatObject($cal));
foreach (
$fields as $val => $name) {
    echo 
"$val ($name)""\n    "$cal->get($val), "\n";
}

The above example will output:

   string(23) "Jul 1, 2013, 4:44:44 AM"
   0 (FIELD_ERA)
       1
   1 (FIELD_YEAR)
       2013
   2 (FIELD_MONTH)
       6
   3 (FIELD_WEEK_OF_YEAR)
       27
   4 (FIELD_WEEK_OF_MONTH)
       1
   5 (FIELD_DAY_OF_MONTH)
       1
   6 (FIELD_DAY_OF_YEAR)
       182
   7 (FIELD_DAY_OF_WEEK)
       2
   8 (FIELD_DAY_OF_WEEK_IN_MONTH)
       1
   9 (FIELD_AM_PM)
       0
   10 (FIELD_HOUR)
       4
   11 (FIELD_HOUR_OF_DAY)
       4
   12 (FIELD_MINUTE)
       44
   13 (FIELD_SECOND)
       44
   14 (FIELD_MILLISECOND)
       551
   15 (FIELD_ZONE_OFFSET)
       0
   16 (FIELD_DST_OFFSET)
       3600000
   17 (FIELD_YEAR_WOY)
       2013
   18 (FIELD_DOW_LOCAL)
       2
   19 (FIELD_EXTENDED_YEAR)
       2013
   20 (FIELD_JULIAN_DAY)
       2456475
   21 (FIELD_MILLISECONDS_IN_DAY)
       17084551
   22 (FIELD_IS_LEAP_MONTH)
       0
   



IntlCalendar::getActualMaximum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getActualMaximumThe maximum value for a field, considering the objectʼs current time

Description

Object oriented style

public IntlCalendar::getActualMaximum ( int $field ) : int

Procedural style

intlcal_get_actual_maximum ( IntlCalendar $cal , int $field ) : int

Returns a fieldʼs relative maximum value around the current time. The exact semantics vary by field, but in the general case this is the value that would be obtained if one would set the field value into the smallest relative maximum for the field and would increment it until reaching the global maximum or the field value wraps around, in which the value returned would be the global maximum or the value before the wrapping, respectively.

For instance, in the gregorian calendar, the actual maximum value for the day of month would vary between 28 and 31, depending on the month and year of the current time.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing the maximum value in the units associated with the given field or FALSE on failure.

Examples

Example #1 IntlCalendar::getActualMaximum()

<?php
ini_set
('date.timezone''Europe/Lisbon');

$cal IntlCalendar::fromDateTime('2013-02-15');
var_dump($cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH)); //28

$cal->add(IntlCalendar::FIELD_EXTENDED_YEAR, -1);
var_dump($cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH)); //29

The above example will output:

   int(28)
   int(29)
   

See Also



IntlCalendar::getActualMinimum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getActualMinimumThe minimum value for a field, considering the objectʼs current time

Description

Object oriented style

public IntlCalendar::getActualMinimum ( int $field ) : int

Procedural style

intlcal_get_actual_minimum ( IntlCalendar $cal , int $field ) : int

Returns a fieldʼs relative minimum value around the current time. The exact semantics vary by field, but in the general case this is the value that would be obtained if one would set the field value into the greatest relative minimum for the field and would decrement it until reaching the global minimum or the field value wraps around, in which the value returned would be the global minimum or the value before the wrapping, respectively.

For the Gregorian calendar, this is always the same as IntlCalendar::getMinimum().

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing the minimum value in the fieldʼs unit or FALSE on failure.

See Also



IntlCalendar::getAvailableLocales

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getAvailableLocalesGet array of locales for which there is data

Description

Object oriented style

public static IntlCalendar::getAvailableLocales ( void ) : array

Procedural style

intlcal_get_available_locales ( void ) : array

Gives the list of locales for which calendars are installed. As of ICU 51, this is the list of all installed ICU locales.

Parameters

This function has no parameters.

Return Values

An array of strings, one for which locale.

Examples

Example #1 IntlCalendar::getAvailableLocales()

<?php
print_r
(IntlCalendar::getAvailableLocales());

The above example will output:

   Array
   (
       [0] => af
       [1] => af_NA
       [2] => af_ZA
       [3] => agq
       [4] => agq_CM
       [5] => ak
       [6] => ak_GH
       [7] => am
       [8] => am_ET
       [9] => ar
       [10] => ar_001
       [11] => ar_AE
       [12] => ar_BH
       [13] => ar_DJ
       … output abbreviated …
       [595] => zh_Hant_HK
       [596] => zh_Hant_MO
       [597] => zh_Hant_TW
       [598] => zu
       [599] => zu_ZA
   )
   



IntlCalendar::getDayOfWeekType

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getDayOfWeekTypeTell whether a day is a weekday, weekend or a day that has a transition between the two

Description

Object oriented style

public IntlCalendar::getDayOfWeekType ( int $dayOfWeek ) : int

Procedural style

intlcal_get_day_of_week_type ( IntlCalendar $cal , int $dayOfWeek ) : int

Returns whether the passed day is a weekday (IntlCalendar::DOW_TYPE_WEEKDAY), a weekend day (IntlCalendar::DOW_TYPE_WEEKEND), a day during which a transition occurs into the weekend (IntlCalendar::DOW_TYPE_WEEKEND_OFFSET) or a day during which the weekend ceases (IntlCalendar::DOW_TYPE_WEEKEND_CEASE).

If the return is either IntlCalendar::DOW_TYPE_WEEKEND_OFFSET or IntlCalendar::DOW_TYPE_WEEKEND_CEASE, then IntlCalendar::getWeekendTransition() can be called to obtain the time of the transition.

This function requires ICU 4.4 or later.

Parameters

cal

The IntlCalendar resource.

dayOfWeek

One of the constants IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY.

Return Values

Returns one of the constants IntlCalendar::DOW_TYPE_WEEKDAY, IntlCalendar::DOW_TYPE_WEEKEND, IntlCalendar::DOW_TYPE_WEEKEND_OFFSET or IntlCalendar::DOW_TYPE_WEEKEND_CEASE or FALSE on failure.

Examples

Example #1 IntlCalendar::getDayOfWeekType()

<?php

foreach (array('en_US''ar_SA') as $locale) {
    echo 
"Locale: "Locale::getDisplayName($locale"en_US"), "\n";

    
$cal IntlCalendar::createInstance('UTC'$locale);

    for (
$i IntlCalendar::DOW_SUNDAY$i <= IntlCalendar::DOW_SATURDAY$i++) {
        echo 
$i" "$cal->getDayOfWeekType($i), " ",
                
$cal->getDayOfWeekType($i) >= IntlCalendar::DOW_TYPE_WEEKEND_OFFSET
                        
$cal->getWeekendTransition($i)
                        : 
'',
                
"\n";
    }
    echo 
"\n";
}

The above example will output:

   Locale: English (United States)
   1 3 86400000
   2 0 
   3 0 
   4 0 
   5 0 
   6 0 
   7 1 
   
   Locale: Arabic (Saudi Arabia)
   1 0 
   2 0 
   3 0 
   4 0 
   5 1 
   6 3 86400000
   7 0 
   
   



IntlCalendar::getErrorCode

intlcal_get_error_code

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getErrorCode -- intlcal_get_error_codeGet last error code on the object

Description

Object oriented style (method):

public IntlCalendar::getErrorCode ( void ) : int

Procedural style:

intlcal_get_error_code ( IntlCalendar $calendar ) : int

Returns the numeric ICU error code for the last call on this object (including cloning) or the IntlCalendar given for the calendar parameter (in the procedural‒style version). This may indicate only a warning (negative error code) or no error at all (U_ZERO_ERROR). The actual presence of an error can be tested with intl_is_failure().

Invalid arguments detected on the PHP side (before invoking functions of the ICU library) are not recorded for the purposes of this function.

The last error that occurred in any call to a function of the intl extension, including early argument errors, can be obtained with intl_get_error_code(). This function resets the global error code, but not the objectʼs error code.

Parameters

calendar

The calendar object, on the procedural style interface.

Return Values

An ICU error code indicating either success, failure or a warning.

Examples

Example #1 IntlCalendar::getErrorCode() and IntlCalendar::getErrorMessage()

<?php
ini_set
("intl.error_level"E_WARNING);
ini_set("intl.default_locale""nl");

$intlcal = new IntlGregorianCalendar(2012129);
var_dump(
    
$intlcal->getErrorCode(),
    
$intlcal->getErrorMessage()
);
$intlcal->fieldDifference(-1e100IntlCalendar::FIELD_SECOND);

var_dump(
    
$intlcal->getErrorCode(),
    
$intlcal->getErrorMessage()
);

The above example will output:

   int(0)
   string(12) "U_ZERO_ERROR"
   
   Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has failed in /home/glopes/php/ws/example.php on line 10
   int(1)
   string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
   

See Also



IntlCalendar::getErrorMessage

intlcal_get_error_message

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getErrorMessage -- intlcal_get_error_messageGet last error message on the object

Description

Object oriented style (method):

public IntlCalendar::getErrorMessage ( void ) : string

Procedural style:

intlcal_get_error_message ( IntlCalendar $calendar ) : string

Returns the error message (if any) associated with the error reported by IntlCalendar::getErrorCode() or intlcal_get_error_code(). If there is no associated error message, only the string representation of the name of the error constant will be returned. Otherwise, the message also includes a message set on the side of the PHP binding.

Parameters

calendar

The calendar object, on the procedural style interface.

Return Values

The error message associated with last error that occurred in a function call on this object, or a string indicating the non-existance of an error.

Examples

Example #1 IntlCalendar::getErrorMessage()

<?php
$cal 
IntlCalendar::createInstance('UTC''en_US');
var_dump($cal->getErrorMessage());

$cal->getWeekendTransition(IntlCalendar::DOW_WEDNESDAY);
var_dump($cal->getErrorMessage());

The above example will output:

   string(12) "U_ZERO_ERROR"
   string(82) "intlcal_get_weekend_transition: Error calling ICU method: U_ILLEGAL_ARGUMENT_ERROR"
   



IntlCalendar::getFirstDayOfWeek

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getFirstDayOfWeekGet the first day of the week for the calendarʼs locale

Description

Object oriented style

public IntlCalendar::getFirstDayOfWeek ( void ) : int

Procedural style

intlcal_get_first_day_of_week ( IntlCalendar $cal ) : int

The week day deemed to start a week, either the default value for this locale or the value set with IntlCalendar::setFirstDayOfWeek().

Parameters

cal

The IntlCalendar resource.

Return Values

One of the constants IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY or FALSE on failure.

Examples

Example #1 IntlCalendar::getFirstDayOfWeek()

<?php
ini_set
('date.timezone''UTC');

$cal1 IntlCalendar::createInstance(NULL'es_ES');
var_dump($cal1->getFirstDayOfWeek()); // Monday
$cal1->set(2013/* February */3); // a Sunday
var_dump($cal1->get(IntlCalendar::FIELD_WEEK_OF_YEAR)); // 5

$cal2 IntlCalendar::createInstance(NULL'en_US');
var_dump($cal2->getFirstDayOfWeek()); // Sunday
$cal2->set(2013/* February */3); // a Sunday
var_dump($cal2->get(IntlCalendar::FIELD_WEEK_OF_YEAR)); // 6

The above example will output:

   int(2)
   int(5)
   int(1)
   int(6)
   

See Also



IntlCalendar::getGreatestMinimum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getGreatestMinimumGet the largest local minimum value for a field

Description

Object oriented style

public IntlCalendar::getGreatestMinimum ( int $field ) : int

Procedural style

intlcal_get_greatest_minimum ( IntlCalendar $cal , int $field ) : int

Returns the largest local minimum for a field. This should be a value larger or equal to that returned by IntlCalendar::getActualMinimum(), which is in its turn larger or equal to that returned by IntlCalendar::getMinimum(). All these three functions return the same value for the Gregorian calendar.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing a field value, in the fieldʼs unit, or FALSE on failure.



IntlCalendar::getKeywordValuesForLocale

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getKeywordValuesForLocaleGet set of locale keyword values

Description

Object oriented style

public static IntlCalendar::getKeywordValuesForLocale ( string $key , string $locale , bool $commonlyUsed ) : Iterator

Procedural style

intlcal_get_keyword_values_for_locale ( string $key , string $locale , bool $commonlyUsed ) : Iterator

For a given locale key, get the set of values for that key that would result in a different behavior. For now, only the 'calendar' keyword is supported.

This function requires ICU 4.2 or later.

Parameters

key

The locale keyword for which relevant values are to be queried. Only 'calendar' is supported.

locale

The locale onto which the keyword/value pair are to be appended.

commonlyUsed

Whether to show only the values commonly used for the specified locale.

Return Values

An iterator that yields strings with the locale keyword values or FALSE on failure.

Examples

Example #1 IntlCalendar::getKeyworkValuesForLocale()

<?php
print_r
(
        
iterator_to_array(
                
IntlCalendar::getKeywordValuesForLocale(
                        
'calendar''fa_IR'true)));
print_r(
        
iterator_to_array(
                
IntlCalendar::getKeywordValuesForLocale(
                        
'calendar''fa_IR'false)));

The above example will output:

   Array
   (
       [0] => persian
       [1] => gregorian
       [2] => islamic
       [3] => islamic-civil
   )
   Array
   (
       [0] => persian
       [1] => gregorian
       [2] => islamic
       [3] => islamic-civil
       [4] => japanese
       [5] => buddhist
       [6] => roc
       [7] => hebrew
       [8] => chinese
       [9] => indian
       [10] => coptic
       [11] => ethiopic
       [12] => ethiopic-amete-alem
   )
   
   



IntlCalendar::getLeastMaximum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getLeastMaximumGet the smallest local maximum for a field

Description

Object oriented style

public IntlCalendar::getLeastMaximum ( int $field ) : int

Procedural style

intlcal_get_least_maximum ( IntlCalendar $cal , int $field ) : int

Returns the smallest local maximumw for a field. This should be a value smaller or equal to that returned by IntlCalendar::getActualMaxmimum(), which is in its turn smaller or equal to that returned by IntlCalendar::getMaximum().

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing a field value in the fieldʼs unit or FALSE on failure.

Examples

Example #1 Maxima examples

<?php
ini_set
('date.timezone''UTC');
ini_set('intl.default_locale''it_IT');

$cal = new IntlGregorianCalendar(2013/* April */6);
var_dump(
    
$cal->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),  // 28
    
$cal->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), // 30
    
$cal->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH)        // 31
);

The above example will output:

   int(28)
   int(30)
   int(31)
   

See Also



IntlCalendar::getLocale

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getLocaleGet the locale associated with the object

Description

Object oriented style

public IntlCalendar::getLocale ( int $localeType ) : string

Procedural style

intlcal_get_locale ( IntlCalendar $cal , int $localeType ) : string

Returns the locale used by this calendar object.

Parameters

cal

The IntlCalendar resource.

localeType

Whether to fetch the actual locale (the locale from which the calendar data originates, with Locale::ACTUAL_LOCALE) or the valid locale, i.e., the most specific locale supported by ICU relatively to the requested locale – see Locale::VALID_LOCALE. From the most general to the most specific, the locales are ordered in this fashion – actual locale, valid locale, requested locale.

Return Values

A locale string or FALSE on failure.

Examples

Example #1 IntlCalendar::getLocale()

<?php
$cal 
IntlCalendar::createInstance(IntlTimeZone::getGMT(), 'en_US_CALIFORNIA');
var_dump(
    
$cal->getLocale(Locale::ACTUAL_LOCALE),
    
$cal->getLocale(Locale::VALID_LOCALE)
);

The above example will output:

   string(2) "en"
   string(5) "en_US"
   



IntlCalendar::getMaximum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getMaximumGet the global maximum value for a field

Description

Object oriented style

public IntlCalendar::getMaximum ( int $field ) : int

Procedural style

intlcal_get_maximum ( IntlCalendar $cal , int $field ) : int

Gets the global maximum for a field, in this specific calendar. This value is larger or equal to that returned by IntlCalendar::getActualMaximum(), which is in its turn larger or equal to that returned by IntlCalendar::getLeastMaximum().

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing a field value in the fieldʼs unit or FALSE on failure.

See Also



IntlCalendar::getMinimalDaysInFirstWeek

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getMinimalDaysInFirstWeekGet minimal number of days the first week in a year or month can have

Description

Object oriented style

public IntlCalendar::getMinimalDaysInFirstWeek ( void ) : int

Procedural style

intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal ) : int

Returns the smallest number of days the first week of a year or month must have in the new year or month. For instance, in the Gregorian calendar, if this value is 1, then the first week of the year will necessarily include January 1st, while if this value is 7, then the week with January 1st will be the first week of the year only if the day of the week for January 1st matches the day of the week returned by IntlCalendar::getFirstDayOfWeek(); otherwise it will be the previous yearʼs last week.

Parameters

cal

The IntlCalendar resource.

Return Values

An int representing a number of days or FALSE on failure.

Examples

Example #1 IntlCalendar::getMinimalDaysInFirstWeek()

<?php
ini_set
('date.timezone''UTC');
ini_set('intl.default_locale''en_US');

$cal = new IntlGregorianCalendar(2013/* January */2);
var_dump(IntlDateFormatter::formatObject($cal'cccc')); // Wednesday

var_dump($cal->getMinimalDaysInFirstWeek(), // 1
$cal->getFirstDayofWeek()); // 1 (Sunday)

// Week 1 of 2013
var_dump(IntlDateFormatter::formatObject($cal"'Week 'w' of 'Y"));

$cal->setMinimalDaysInFirstWeek(4);
// Still Week 1 of 2013 (1st week has 5 days in the new year)
var_dump(IntlDateFormatter::formatObject($cal"'Week 'w' of 'Y"));

$cal->setMinimalDaysInFirstWeek(6);
// Week 53 of 2012
var_dump(IntlDateFormatter::formatObject($cal"'Week 'w' of 'Y"));

The above example will output:

   string(9) "Wednesday"
   int(1)
   int(1)
   string(14) "Week 1 of 2013"
   string(14) "Week 1 of 2013"
   string(15) "Week 53 of 2012"
   



IntlCalendar::getMinimum

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getMinimumGet the global minimum value for a field

Description

Object oriented style

public IntlCalendar::getMinimum ( int $field ) : int

Procedural style

intlcal_get_minimum ( IntlCalendar $cal , int $field ) : int

Gets the global minimum for a field, in this specific calendar. This value is smaller or equal to that returned by IntlCalendar::getActualMinimum(), which is in its turn smaller or equal to that returned by IntlCalendar::getGreatestMinimum(). For the Gregorian calendar, these three functions always return the same value (for each field).

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

An int representing a value for the given field in the fieldʼs unit or FALSE on failure.



IntlCalendar::getNow

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getNowGet number representing the current time

Description

Object oriented style

public static IntlCalendar::getNow ( void ) : float

Procedural style

intlcal_get_now ( void ) : float

The number of milliseconds that have passed since the reference date. This number is derived from the system time.

Parameters

This function has no parameters.

Return Values

A float representing a number of milliseconds since the epoch, not counting leap seconds.

Examples

Example #1 IntlCalendar::getNow()

<?php
$formatter 
IntlDateFormatter::create('es_ES',
        
IntlDateFormatter::FULL,
        
IntlDateFormatter::FULL,
        
'Europe/Madrid');

$val IntlCalendar::getNow();

var_dump($val);
echo 
$formatter->format(IntlCalendar::getNow() / 1000.), "\n";

The above example will output:

   float(1371425814666)
   lunes, 17 de junio de 2013 01:36:54 Hora de verano de Europa central
   



IntlCalendar::getRepeatedWallTimeOption

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getRepeatedWallTimeOptionGet behavior for handling repeating wall time

Description

Object oriented style

public IntlCalendar::getRepeatedWallTimeOption ( void ) : int

Procedural style

intlcal_get_repeated_wall_time_option ( IntlCalendar $cal ) : int

Gets the current strategy for dealing with wall times that are repeated whenever the clock is set back during dailight saving time end transitions. The default value is IntlCalendar::WALLTIME_LAST.

This function requires ICU 4.9 or later.

Parameters

cal

The IntlCalendar resource.

Return Values

One of the constants IntlCalendar::WALLTIME_FIRST or IntlCalendar::WALLTIME_LAST.

Examples

Example #1 IntlCalendar::getRepeatedWallTimeOption()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');
ini_set('intl.error_level'E_WARNING);

//On October 27th at 0200, the clock goes back 1 hour and from GMT+01 to GMT+00
$cal = new IntlGregorianCalendar(2013/* October */27130);

var_dump($cal->getRepeatedWalltimeOption()); // 0 WALLTIME_LAST

$formatter IntlDateFormatter::create(
    
NULL,
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'UTC'
);
var_dump($formatter->format($cal->getTime() / 1000.));

$cal->setRepeatedWalltimeOption(IntlCalendar::WALLTIME_FIRST);
var_dump($cal->getRepeatedWalltimeOption()); // 1 WALLTIME_FIRST
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1);

var_dump($formatter->format($cal->getTime() / 1000.));

The above example will output:

   int(0)
   string(42) "Sunday, October 27, 2013 at 1:30:00 AM GMT"
   int(1)
   string(43) "Sunday, October 27, 2013 at 12:30:00 AM GMT"
   

See Also



IntlCalendar::getSkippedWallTimeOption

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getSkippedWallTimeOptionGet behavior for handling skipped wall time

Description

Object oriented style

public IntlCalendar::getSkippedWallTimeOption ( void ) : int

Procedural style

intlcal_get_skipped_wall_time_option ( IntlCalendar $cal ) : int

Gets the current strategy for dealing with wall times that are skipped whenever the clock is forwarded during dailight saving time start transitions. The default value is IntlCalendar::WALLTIME_LAST.

The calendar must be lenient for this option to have any effect, otherwise attempting to set a non-existing time will cause an error.

This function requires ICU 4.9 or later.

Parameters

cal

The IntlCalendar resource.

Return Values

One of the constants IntlCalendar::WALLTIME_FIRST, IntlCalendar::WALLTIME_LAST or IntlCalendar::WALLTIME_NEXT_VALID.

Examples

Example #1 IntlCalendar::getSkippedWallTimeOption()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');
ini_set('intl.error_level'E_WARNING);

//On March 31st at 0100, the clock goes forward 1 hour and from GMT+00 to GMT+01
$cal = new IntlGregorianCalendar(2013/* March */31130);

var_dump(
    
$cal->isLenient(),               // true
    
$cal->getSkippedWalltimeOption() // 0 WALLTIME_LAST
);

$formatter IntlDateFormatter::create(
    
NULL,
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'UTC'
);
var_dump($formatter->format($cal->getTime() / 1000));

$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
var_dump($cal->getSkippedWalltimeOption()); // 1 WALLTIME_FIRST
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1);

var_dump($formatter->format($cal->getTime() / 1000));

$cal->setSkippedWallTimeOption(IntlCalendar::WALLTIME_NEXT_VALID);
var_dump($cal->getSkippedWalltimeOption()); // 2 WALLTIME_NEXT_VALID
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1);

var_dump($formatter->format($cal->getTime() / 1000));

The above example will output:

   bool(true)
   int(0)
   string(40) "Sunday, March 31, 2013 at 1:30:00 AM GMT"
   int(1)
   string(41) "Sunday, March 31, 2013 at 12:30:00 AM GMT"
   int(2)
   string(40) "Sunday, March 31, 2013 at 1:00:00 AM GMT"
   

See Also



IntlCalendar::getTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getTimeGet time currently represented by the object

Description

Object oriented style

public IntlCalendar::getTime ( void ) : float

Procedural style

intlcal_get_time ( IntlCalendar $cal ) : float

Returns the time associated with this object, expressed as the number of milliseconds since the epoch.

Parameters

cal

The IntlCalendar resource.

Return Values

A float representing the number of milliseconds elapsed since the reference time (1 Jan 1970 00:00:00 UTC).

Examples

Example #1 IntlCalendar::getTime()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');

$cal = new IntlGregorianCalendar(2013/* May */1000);
$time $cal->getTime();
var_dump($time$time 1000 == strtotime('2013-05-01 00:00:00')); //true

The above example will output:

   float(1367362800000)
   bool(true)
   

See Also



IntlCalendar::getTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getTimeZoneGet the objectʼs timezone

Description

Object oriented style

public IntlCalendar::getTimeZone ( void ) : IntlTimeZone

Procedural style

intlcal_get_time_zone ( IntlCalendar $cal ) : IntlTimeZone

Returns the IntlTimeZone object associated with this calendar.

Parameters

cal

The IntlCalendar resource.

Return Values

An IntlTimeZone object corresponding to the one used internally in this object.

Examples

Example #1 IntlCalendar::getTimeZone()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');

$cal IntlCalendar::createInstance();
print_r($cal->getTimeZone());

$cal->setTimeZone('UTC');
print_r($cal->getTimeZone());

$cal IntlCalendar::fromDateTime('2012-01-01 00:00:00 GMT+03:33');
print_r($cal->getTimeZone());

The above example will output:

   IntlTimeZone Object
   (
       [valid] => 1
       [id] => Europe/Lisbon
       [rawOffset] => 0
       [currentOffset] => 3600000
   )
   IntlTimeZone Object
   (
       [valid] => 1
       [id] => UTC
       [rawOffset] => 0
       [currentOffset] => 0
   )
   IntlTimeZone Object
   (
       [valid] => 1
       [id] => GMT+03:33
       [rawOffset] => 12780000
       [currentOffset] => 12780000
   )
   

See Also



IntlCalendar::getType

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getTypeGet the calendar type

Description

Object oriented style

public IntlCalendar::getType ( void ) : string

Procedural style

intlcal_get_type ( IntlCalendar $cal ) : string

A string describing the type of this calendar. This is one of the valid values for the calendar keyword value 'calendar'.

Parameters

cal

The IntlCalendar resource.

Return Values

A string representing the calendar type, such as 'gregorian', 'islamic', etc.

Examples

Example #1 IntlCalendar::getType()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''en_US');

$cal IntlCalendar::createInstance(NULL'@calendar=ethiopic-amete-alem');
var_dump($cal->getType());

$cal = new IntlGregorianCalendar();
var_dump($cal->getType());

The above example will output:

   string(19) "ethiopic-amete-alem"
   string(9) "gregorian"
   



IntlCalendar::getWeekendTransition

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::getWeekendTransitionGet time of the day at which weekend begins or ends

Description

Object oriented style

public IntlCalendar::getWeekendTransition ( string $dayOfWeek ) : int

Procedural style

intlcal_get_weekend_transition ( IntlCalendar $cal , string $dayOfWeek ) : int

Returns the number of milliseconds after midnight at which the weekend begins or ends.

This is only applicable for days of the week for which IntlCalendar::getDayOfWeekType() returns either IntlCalendar::DOW_TYPE_WEEKEND_OFFSET or IntlCalendar::DOW_TYPE_WEEKEND_CEASE. Calling this function for other days of the week is an error condition.

This function requires ICU 4.4 or later.

Parameters

cal

The IntlCalendar resource.

dayOfWeek

One of the constants IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY.

Return Values

The number of milliseconds into the day at which the weekend begins or ends or FALSE on failure.

Examples

See example on IntlCalendar::getDayOfWeekType().



IntlCalendar::inDaylightTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::inDaylightTimeWhether the objectʼs time is in Daylight Savings Time

Description

Object oriented style

public IntlCalendar::inDaylightTime ( void ) : bool

Procedural style

intlcal_in_daylight_time ( IntlCalendar $cal ) : bool

Whether, for the instant represented by this object and for this objectʼs timezone, daylight saving time is in place.

Parameters

cal

The IntlCalendar resource.

Return Values

Returns TRUE if the date is in Daylight Savings Time, FALSE otherwise. The value FALSE may also be returned on failure, for instance after specifying invalid field values on non-lenient mode; use exceptions or query intl_get_error_code() to disambiguate.

Examples

Example #1 IntlCalendar::inDaylightTime()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''pt_PT');

$cal = new IntlGregorianCalendar(2013/* July */145631);
var_dump($cal->inDaylightTime()); // true
$cal->set(IntlCalendar::FIELD_MONTH11 /* December */);
var_dump($cal->inDaylightTime()); // false

//DST end transition on 2013-10-27 at 0200 (wall time back 1 hour)
$cal = new IntlGregorianCalendar(2013/* October */271300);

var_dump($cal->inDaylightTime()); // false (default WALLTIME_LAST)

$cal->setRepeatedWallTimeOption(IntlCalendar::WALLTIME_FIRST);
$cal->set(IntlCalendar::FIELD_HOUR_OF_DAY1); // force time recalculation
var_dump($cal->inDaylightTime()); // true



IntlCalendar::isEquivalentTo

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::isEquivalentToWhether another calendar is equal but for a different time

Description

Object oriented style

public IntlCalendar::isEquivalentTo ( IntlCalendar $other ) : bool

Procedural style

intlcal_is_equivalent_to ( IntlCalendar $cal , IntlCalendar $other ) : bool

Returns whether this and the given object are equivalent for all purposes except as to the time they have set. The locales do not have to match, as long as no change in behavior results from such mismatch. This includes the timezone, whether the lenient mode is set, the repeated and skipped wall time settings, the days of the week when the weekend starts and ceases and the times where such transitions occur. It may also include other calendar specific settings, such as the Gregorian/Julian transition instant.

Parameters

cal

The IntlCalendar resource.

other

The other calendar against which the comparison is to be made.

Return Values

Assuming there are no argument errors, returns TRUE if the calendars are equivalent except possibly for their set time.

Examples

Example #1 IntlCalendar::isEquivalentTo()

<?php
$cal1 
IntlCalendar::createInstance('Europe/Lisbon''pt_PT');
$cal2 IntlCalendar::createInstance('Europe/Lisbon''es_ES');
$cal2->clear();

var_dump($cal1->isEquivalentTo($cal2)); // true

$cal3 IntlCalendar::createInstance('Europe/Lisbon''en_US');
var_dump($cal1->isEquivalentTo($cal3)); // false
var_dump($cal1->getFirstDayOfWeek(),    // 2 (Monday)
$cal3->getFirstDayOfWeek());            // 1 (Sunday)

The above example will output:

   bool(true)
   bool(false)
   int(2)
   int(1)
   

See Also



IntlCalendar::isLenient

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::isLenientWhether date/time interpretation is in lenient mode

Description

Object oriented style

public IntlCalendar::isLenient ( void ) : bool

Procedural style

intlcal_is_lenient ( IntlCalendar $cal ) : bool

Returns whether the current date/time interpretations is lenient (the default). If that is case, some out of range values for fields will be accepted instead of raising an error.

Parameters

cal

The IntlCalendar resource.

Return Values

A bool representing whether the calendar is set to lenient mode.

Examples

Example #1 IntlCalendar::isLenient()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''pt_PT');
ini_set('intl.use_exceptions''1');

$cal = new IntlGregorianCalendar(2013/* July */1);
var_dump(IntlDateFormatter::formatObject($cal), // 01/07/2013, 00:00:00
$cal->isLenient()); // true

$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH33);
var_dump(IntlDateFormatter::formatObject($cal)); // 02/08/2013, 00:00:00

$cal->setLenient(false);
var_dump($cal->isLenient()); // false
$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH33);
var_dump(IntlDateFormatter::formatObject($cal)); // error

The above example will output:

   string(20) "01/07/2013, 00:00:00"
   bool(true)
   string(20) "02/08/2013, 00:00:00"
   bool(false)
   
   Fatal error: Uncaught exception 'IntlException' with message 'datefmt_format_object: error obtaining instant from IntlCalendar' in /home/foobar/example.php:16
   Stack trace:
   #0 /home/foobar/example.php(16): IntlDateFormatter::formatObject(Object(IntlGregorianCalendar))
   #1 {main}
     thrown in /home/foobar/example.php on line 16
   



IntlCalendar::isSet

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::isSetWhether a field is set

Description

Object oriented style

public IntlCalendar::isSet ( int $field ) : bool

Procedural style

intlcal_is_set ( IntlCalendar $cal , int $field ) : bool

Returns whether a field is set (as opposed to clear). Set fields take priority over unset fields and their default values when the date/time is being calculated. Fields set later take priority over fields set earlier.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

Return Values

Assuming there are no argument errors, returns TRUE if the field is set.

Examples

See the example on IntlCalendar::clear().

See Also



IntlCalendar::isWeekend

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::isWeekendWhether a certain date/time is in the weekend

Description

Object oriented style

public IntlCalendar::isWeekend ([ float $date = NULL ] ) : bool

Procedural style

intlcal_is_weekend ( IntlCalendar $cal [, float $date = NULL ] ) : bool

Returns whether either the obejctʼs current time or the provided timestamp occur during a weekend in this objectʼs calendar system.

This function requires ICU 4.4 or later.

Parameters

cal

The IntlCalendar resource.

date

An optional timestamp representing the number of milliseconds since the epoch, excluding leap seconds. If NULL, this objectʼs current time is used instead.

Return Values

A bool indicating whether the given or this objectʼs time occurs in a weekend.

The value FALSE may also be returned on failure, for instance after giving a date out of bounds on non-lenient mode; use exceptions or query intl_get_error_code() to disambiguate.

Examples

Example #1 IntlCalendar::isWeekend()

<?php
ini_set
('date.timezone''Europe/Lisbon');

$cal = new IntlGregorianCalendar(NULL'en_US');
$cal->set(2013/* July */7); // a Sunday 

var_dump($cal->isWeekend()); // true
var_dump($cal->isWeekend(strtotime('2013-07-01 00:00:00'))); // false, Monday

$cal = new IntlGregorianCalendar(NULL'ar_SA');
$cal->set(2013/* July */7); // a Sunday 
var_dump($cal->isWeekend()); // false, Sunday not in weekend in this calendar

See Also



IntlCalendar::roll

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::rollAdd value to field without carrying into more significant fields

Description

Object oriented style

public IntlCalendar::roll ( int $field , mixed $amountOrUpOrDown ) : bool

Procedural style

intlcal_roll ( IntlCalendar $cal , int $field , mixed $amountOrUpOrDown ) : bool

Adds a (signed) amount to a field. The difference with respect to IntlCalendar::add() is that when the field value overflows, it does not carry into more significant fields.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

amountOrUpOrDown

The (signed) amount to add to the field, TRUE for rolling up (adding 1), or FALSE for rolling down (subtracting 1).

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 IntlCalendar::roll()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''pt_PT');

$cal = new IntlGregorianCalendar(2013/* June */30);

$cal->add(IntlCalendar::FIELD_DAY_OF_MONTH1);
var_dump(IntlDateFormatter::formatObject($cal)); // "01/07/2013, 00:00:00"

$cal->set(2013/* June */30);
$cal->roll(IntlCalendar::FIELD_DAY_OF_MONTHtrue); // roll up, same as rolling +1
var_dump(IntlDateFormatter::formatObject($cal)); // "01/06/2013, 00:00:00"

The above example will output:

   string(20) "01/07/2013, 00:00:00"
   string(20) "01/06/2013, 00:00:00"
   

See Also



IntlCalendar::set

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setSet a time field or several common fields at once

Description

Object oriented style

public IntlCalendar::set ( int $field , int $value ) : bool
public IntlCalendar::set ( int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool

Procedural style

intlcal_set ( IntlCalendar $cal , int $field , int $value ) : bool
intlcal_set ( IntlCalendar $cal , int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool

Sets either a specific field to the given value, or sets at once several common fields. The range of values that are accepted depend on whether the calendar is using the lenient mode.

For fields that conflict, the fields that are set later have priority.

This method cannot be called with exactly four arguments.

Parameters

cal

The IntlCalendar resource.

field

One of the IntlCalendar date/time field constants. These are integer values between 0 and IntlCalendar::FIELD_COUNT.

value

The new value of the given field.

year

The new value for IntlCalendar::FIELD_YEAR.

month

The new value for IntlCalendar::FIELD_MONTH.

dayOfMonth

The new value for IntlCalendar::FIELD_DAY_OF_MONTH. The month sequence is zero-based, i.e., January is represented by 0, February by 1, …, December is 11 and Undecember (if the calendar has it) is 12.

hour

The new value for IntlCalendar::FIELD_HOUR_OF_DAY.

minute

The new value for IntlCalendar::FIELD_MINUTE.

second

The new value for IntlCalendar::FIELD_SECOND.

Return Values

Returns TRUE on success and FALSE on failure.

Examples

Example #1 IntlCalendar::set()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''pt_PT');

//Calls made later have priority
$cal = new IntlGregorianCalendar(2013/* July */1);
$cal->set(IntlCalendar::FIELD_YEAR2012);
$cal->set(IntlCalendar::FIELD_EXTENDED_YEAR2011);
var_dump(IntlDateFormatter::formatObject($cal));


$cal = new IntlGregorianCalendar(2013/* July */1);
$cal->set(IntlCalendar::FIELD_YEAR2012);
$cal->set(IntlCalendar::FIELD_EXTENDED_YEAR2011);
//the time has not been recalculated yet. If we clear the extended year,
//the year set before will be used
$cal->clear(IntlCalendar::FIELD_EXTENDED_YEAR);
var_dump(IntlDateFormatter::formatObject($cal));

The above example will output:

   string(20) "01/07/2011, 00:00:00"
   string(20) "01/07/2012, 00:00:00"
   

See Also



IntlCalendar::setFirstDayOfWeek

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setFirstDayOfWeekSet the day on which the week is deemed to start

Description

Object oriented style

public IntlCalendar::setFirstDayOfWeek ( int $dayOfWeek ) : bool

Procedural style

intlcal_set_first_day_of_week ( IntlCalendar $cal , int $dayOfWeek ) : bool

Defines the day of week deemed to start the week. This affects the behavior of fields that depend on the concept of week start and end such as IntlCalendar::FIELD_WEEK_OF_YEAR and IntlCalendar::FIELD_YEAR_WOY.

Parameters

cal

The IntlCalendar resource.

dayOfWeek

One of the constants IntlCalendar::DOW_SUNDAY, IntlCalendar::DOW_MONDAY, …, IntlCalendar::DOW_SATURDAY.

Return Values

Returns TRUE on success. Failure can only happen due to invalid parameters.

Examples

Example #1 IntlCalendar::setFirstDayOfWeek()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''es_ES');

$cal IntlCalendar::createInstance();
$cal->set(2013/* June */30); // A Sunday

var_dump($cal->getFirstDayOfWeek()); // 2 (Monday)

echo IntlDateFormatter::formatObject($cal, <<<EOD
'local day of week: 'cc'
week of month    : 'W'
week of year     : 'ww
EOD
), 
"\n";

$cal->setFirstDayOfWeek(IntlCalendar::DOW_SUNDAY);

echo 
IntlDateFormatter::formatObject($cal, <<<EOD
'local day of week: 'cc'
week of month    : 'W'
week of year     : 'ww
EOD
), 
"\n";

The above example will output:

   int(2)
   local day of week: 7
   week of month    : 4
   week of year     : 26
   local day of week: 1
   week of month    : 5
   week of year     : 27
   



IntlCalendar::setLenient

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setLenientSet whether date/time interpretation is to be lenient

Description

Object oriented style

public IntlCalendar::setLenient ( bool $isLenient ) : bool

Procedural style

intlcal_set_lenient ( IntlCalendar $cal , bool $isLenient ) : bool

Defines whether the calendar is ‘lenient mode’. In such a mode, some of out-of-bounds values for some fields are accepted, the behavior being similar to that of IntlCalendar::add() (i.e., the value wraps around, carrying into more significant fields each time). If the lenient mode is off, then such values will generate an error.

Parameters

cal

The IntlCalendar resource.

isLenient

Use TRUE to activate the lenient mode; FALSE otherwise.

Return Values

Returns TRUE on success. Failure can only happen due to invalid parameters.

Examples

See the example in IntlCalendar::isLenient().



IntlCalendar::setMinimalDaysInFirstWeek

(PHP 5 >= 5.5.1, PHP 7)

IntlCalendar::setMinimalDaysInFirstWeekSet minimal number of days the first week in a year or month can have

Description

Object oriented style

public IntlCalendar::setMinimalDaysInFirstWeek ( int $minimalDays ) : bool

Procedural style

intlcal_set_minimal_days_in_first_week ( IntlCalendar $cal , int $minimalDays ) : bool

Sets the smallest number of days the first week of a year or month must have in the new year or month. For instance, in the Gregorian calendar, if this value is 1, then the first week of the year will necessarily include January 1st, while if this value is 7, then the week with January 1st will be the first week of the year only if the day of the week for January 1st matches the day of the week returned by IntlCalendar::getFirstDayOfWeek(); otherwise it will be the previous yearʼs last week.

Parameters

cal

The IntlCalendar resource.

minimalDays

The number of minimal days to set.

Return Values

TRUE on success, FALSE on failure.



IntlCalendar::setRepeatedWallTimeOption

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setRepeatedWallTimeOptionSet behavior for handling repeating wall times at negative timezone offset transitions

Description

Object oriented style

public IntlCalendar::setRepeatedWallTimeOption ( int $wallTimeOption ) : bool

Procedural style

intlcal_set_repeated_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool

Sets the current strategy for dealing with wall times that are repeated whenever the clock is set back during dailight saving time end transitions. The default value is IntlCalendar::WALLTIME_LAST (take the post-DST instant). The other possible value is IntlCalendar::WALLTIME_FIRST (take the instant that occurs during DST).

This function requires ICU 4.9 or later.

Parameters

cal

The IntlCalendar resource.

wallTimeOption

One of the constants IntlCalendar::WALLTIME_FIRST or IntlCalendar::WALLTIME_LAST.

Return Values

Returns TRUE on success. Failure can only happen due to invalid parameters.

Examples

See the example on IntlCalendar::getRepeatedWallTimeOption().

See Also



IntlCalendar::setSkippedWallTimeOption

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setSkippedWallTimeOptionSet behavior for handling skipped wall times at positive timezone offset transitions

Description

Object oriented style

public IntlCalendar::setSkippedWallTimeOption ( int $wallTimeOption ) : bool

Procedural style

intlcal_set_skipped_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool

Sets the current strategy for dealing with wall times that are skipped whenever the clock is forwarded during dailight saving time start transitions. The default value is IntlCalendar::WALLTIME_LAST (take it as being the same instant as the one when the wall time is one hour more). Alternative values are IntlCalendar::WALLTIME_FIRST (same instant as the one with a wall time of one hour less) and IntlCalendar::WALLTIME_NEXT_VALID (same instant as when DST begins).

This affects only the instant represented by the calendar (as reported by IntlCalendar::getTime()), the field values will not be rewritten accordingly.

The calendar must be lenient for this option to have any effect, otherwise attempting to set a non-existing time will cause an error.

This function requires ICU 4.9 or later.

Parameters

cal

The IntlCalendar resource.

wallTimeOption

One of the constants IntlCalendar::WALLTIME_FIRST, IntlCalendar::WALLTIME_LAST or IntlCalendar::WALLTIME_NEXT_VALID.

Return Values

Returns TRUE on success. Failure can only happen due to invalid parameters.

Examples

See the example on IntlCalendar::getSkippedWallTimeOption().

See Also



IntlCalendar::setTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setTimeSet the calendar time in milliseconds since the epoch

Description

Object oriented style

public IntlCalendar::setTime ( float $date ) : bool

Procedural style

intlcal_set_time ( IntlCalendar $cal , float $date ) : bool

Sets the instant represented by this object. The instant is represented by a float whose value should be an integer number of milliseconds since the epoch (1 Jan 1970 00:00:00.000 UTC), ignoring leap seconds. All the field values will be recalculated accordingly.

Parameters

cal

The IntlCalendar resource.

date

An instant represented by the number of number of milliseconds between such instant and the epoch, ignoring leap seconds.

Return Values

Returns TRUE on success and FALSE on failure.

Examples

Example #1 IntlCalendar::setTime()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''fr_FR');

$cal = new IntlGregorianCalendar(2013/* May */11200);

echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";

/* In Europe/Lisbon, on 2013-10-27 at 0200, the clock goes back one hour and
   the timezone from UTC+01 to UTC+00 */

$cal->setTime(strtotime('2013-10-27 00:30:00 UTC') * 1000.);

echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";

$cal->setTime(strtotime('2013-10-27 01:30:00 UTC') * 1000.);

echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";

The above example will output:

   samedi 1 juin 2013 12:00:00 heure avancée d’Europe de l’Ouest
   dimanche 27 octobre 2013 01:30:00 heure avancée d’Europe de l’Ouest
   dimanche 27 octobre 2013 01:30:00 heure normale d’Europe de l’Ouest
   



IntlCalendar::setTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlCalendar::setTimeZoneSet the timezone used by this calendar

Description

Object oriented style

public IntlCalendar::setTimeZone ( mixed $timeZone ) : bool

Procedural style

intlcal_set_time_zone ( IntlCalendar $cal , mixed $timeZone ) : bool

Defines a new timezone for this calendar. The time represented by the object is preserved to the detriment of the field values.

Parameters

cal

The IntlCalendar resource.

timeZone

The new timezone to be used by this calendar. It can be specified in the following ways:

Return Values

Returns TRUE on success and FALSE on failure.

Examples

Example #1 IntlCalendar::setTimeZone()

<?php
ini_set
('date.timezone''Europe/Lisbon');
ini_set('intl.default_locale''es_ES');

$cal = new IntlGregorianCalendar(2013/* May */11200);

echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";
echo 
"(instant {$cal->getTime()})\n";

$cal->setTimeZone(IntlTimeZone::getGMT());
echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";
echo 
"(instant {$cal->getTime()})\n";

$cal->setTimeZone('GMT+03:33');
echo 
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL), "\n";
echo 
"(instant {$cal->getTime()})\n";

The above example will output:

   sábado, 1 de junio de 2013 12:00:00 Hora de verano de Europa occidental
   (instant 1370084400000)
   sábado, 1 de junio de 2013 11:00:00 GMT
   (instant 1370084400000)
   sábado, 1 de junio de 2013 14:33:00 GMT+03:33
   (instant 1370084400000)
   



IntlCalendar::toDateTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a2)

IntlCalendar::toDateTimeConvert an IntlCalendar into a DateTime object

Description

Object oriented style

public IntlCalendar::toDateTime ( void ) : DateTime

Procedural style

intlcal_to_date_time ( IntlCalendar $cal ) : DateTime

Create a DateTime object that represents the same instant (up to second precision, with a rounding error of less than 1 second) and has an analog timezone to this object (the difference being DateTimeʼs timezone will be backed by PHPʼs timezone while IntlCalendarʼs timezone is backed by ICUʼs).

Parameters

cal

The IntlCalendar resource.

Return Values

A DateTime object with the same timezone as this object (though using PHPʼs database instead of ICUʼs) and the same time, except for the smaller precision (second precision instead of millisecond). Returns FALSE on failure.

Examples

Example #1 IntlCalendar::toDateTime()

<?php
ini_set
('date.timezone''UTC');
ini_set('intl.default_locale''pt_PT');

$cal IntlCalendar::createInstance('Europe/Lisbon'); //current time

$dt $cal->toDateTime();
print_r($dt);

The above example will output:

   DateTime Object
   (
       [date] => 2013-07-02 00:29:13
       [timezone_type] => 3
       [timezone] => Europe/Lisbon
   )
   

See Also


Table of Contents



The IntlGregorianCalendar class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

Class synopsis

IntlGregorianCalendar extends IntlCalendar {
/* Inherited constants */
const integer IntlCalendar::FIELD_ERA = 0 ;
const integer IntlCalendar::FIELD_YEAR = 1 ;
const integer IntlCalendar::FIELD_MONTH = 2 ;
const integer IntlCalendar::FIELD_WEEK_OF_YEAR = 3 ;
const integer IntlCalendar::FIELD_WEEK_OF_MONTH = 4 ;
const integer IntlCalendar::FIELD_DATE = 5 ;
const integer IntlCalendar::FIELD_DAY_OF_YEAR = 6 ;
const integer IntlCalendar::FIELD_DAY_OF_WEEK = 7 ;
const integer IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH = 8 ;
const integer IntlCalendar::FIELD_AM_PM = 9 ;
const integer IntlCalendar::FIELD_HOUR = 10 ;
const integer IntlCalendar::FIELD_HOUR_OF_DAY = 11 ;
const integer IntlCalendar::FIELD_MINUTE = 12 ;
const integer IntlCalendar::FIELD_SECOND = 13 ;
const integer IntlCalendar::FIELD_MILLISECOND = 14 ;
const integer IntlCalendar::FIELD_ZONE_OFFSET = 15 ;
const integer IntlCalendar::FIELD_DST_OFFSET = 16 ;
const integer IntlCalendar::FIELD_YEAR_WOY = 17 ;
const integer IntlCalendar::FIELD_DOW_LOCAL = 18 ;
const integer IntlCalendar::FIELD_EXTENDED_YEAR = 19 ;
const integer IntlCalendar::FIELD_JULIAN_DAY = 20 ;
const integer IntlCalendar::FIELD_MILLISECONDS_IN_DAY = 21 ;
const integer IntlCalendar::FIELD_IS_LEAP_MONTH = 22 ;
const integer IntlCalendar::FIELD_FIELD_COUNT = 23 ;
const integer IntlCalendar::FIELD_DAY_OF_MONTH = 5 ;
const integer IntlCalendar::DOW_SUNDAY = 1 ;
const integer IntlCalendar::DOW_MONDAY = 2 ;
const integer IntlCalendar::DOW_TUESDAY = 3 ;
const integer IntlCalendar::DOW_WEDNESDAY = 4 ;
const integer IntlCalendar::DOW_THURSDAY = 5 ;
const integer IntlCalendar::DOW_FRIDAY = 6 ;
const integer IntlCalendar::DOW_SATURDAY = 7 ;
const integer IntlCalendar::DOW_TYPE_WEEKDAY = 0 ;
const integer IntlCalendar::DOW_TYPE_WEEKEND = 1 ;
const integer IntlCalendar::DOW_TYPE_WEEKEND_OFFSET = 2 ;
const integer IntlCalendar::DOW_TYPE_WEEKEND_CEASE = 3 ;
const integer IntlCalendar::WALLTIME_FIRST = 1 ;
const integer IntlCalendar::WALLTIME_LAST = 0 ;
const integer IntlCalendar::WALLTIME_NEXT_VALID = 2 ;
/* Methods */
public __construct ([ IntlTimeZone $tz [, string $locale ]] )
public getGregorianChange ( void ) : float
public isLeapYear ( int $year ) : bool
public setGregorianChange ( float $date ) : bool
/* Inherited methods */
public IntlCalendar::add ( int $field , int $amount ) : bool
intlcal_add ( IntlCalendar $cal , int $field , int $amount ) : bool
public IntlCalendar::after ( IntlCalendar $other ) : bool
intlcal_after ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::before ( IntlCalendar $other ) : bool
intlcal_before ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::clear ([ int $field = NULL ] ) : bool
intlcal_clear ( IntlCalendar $cal [, int $field = NULL ] ) : bool
private IntlCalendar::__construct ( void )
public static IntlCalendar::createInstance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar
intlcal_create_instance ([ mixed $timeZone = NULL [, string $locale = "" ]] ) : IntlCalendar
public IntlCalendar::equals ( IntlCalendar $other ) : bool
intlcal_equals ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::fieldDifference ( float $when , int $field ) : int
intlcal_field_difference ( IntlCalendar $cal , float $when , int $field ) : int
public static IntlCalendar::fromDateTime ( mixed $dateTime ) : IntlCalendar
intlcal_from_date_time ( mixed $dateTime ) : IntlCalendar
public IntlCalendar::get ( int $field ) : int
intlcal_get ( IntlCalendar $cal , int $field ) : int
public IntlCalendar::getActualMaximum ( int $field ) : int
intlcal_get_actual_maximum ( IntlCalendar $cal , int $field ) : int
public IntlCalendar::getActualMinimum ( int $field ) : int
intlcal_get_actual_minimum ( IntlCalendar $cal , int $field ) : int
public static IntlCalendar::getAvailableLocales ( void ) : array
intlcal_get_available_locales ( void ) : array
public IntlCalendar::getDayOfWeekType ( int $dayOfWeek ) : int
intlcal_get_day_of_week_type ( IntlCalendar $cal , int $dayOfWeek ) : int
public IntlCalendar::getErrorCode ( void ) : int
public IntlCalendar::getErrorMessage ( void ) : string
public IntlCalendar::getFirstDayOfWeek ( void ) : int
intlcal_get_first_day_of_week ( IntlCalendar $cal ) : int
public IntlCalendar::getGreatestMinimum ( int $field ) : int
intlcal_get_greatest_minimum ( IntlCalendar $cal , int $field ) : int
public static IntlCalendar::getKeywordValuesForLocale ( string $key , string $locale , bool $commonlyUsed ) : Iterator
intlcal_get_keyword_values_for_locale ( string $key , string $locale , bool $commonlyUsed ) : Iterator
public IntlCalendar::getLeastMaximum ( int $field ) : int
intlcal_get_least_maximum ( IntlCalendar $cal , int $field ) : int
public IntlCalendar::getLocale ( int $localeType ) : string
intlcal_get_locale ( IntlCalendar $cal , int $localeType ) : string
public IntlCalendar::getMaximum ( int $field ) : int
intlcal_get_maximum ( IntlCalendar $cal , int $field ) : int
intlcal_get_minimal_days_in_first_week ( IntlCalendar $cal ) : int
public IntlCalendar::getMinimum ( int $field ) : int
intlcal_get_minimum ( IntlCalendar $cal , int $field ) : int
public static IntlCalendar::getNow ( void ) : float
intlcal_get_now ( void ) : float
intlcal_get_repeated_wall_time_option ( IntlCalendar $cal ) : int
intlcal_get_skipped_wall_time_option ( IntlCalendar $cal ) : int
public IntlCalendar::getTime ( void ) : float
intlcal_get_time ( IntlCalendar $cal ) : float
intlcal_get_time_zone ( IntlCalendar $cal ) : IntlTimeZone
public IntlCalendar::getType ( void ) : string
intlcal_get_type ( IntlCalendar $cal ) : string
public IntlCalendar::getWeekendTransition ( string $dayOfWeek ) : int
intlcal_get_weekend_transition ( IntlCalendar $cal , string $dayOfWeek ) : int
public IntlCalendar::inDaylightTime ( void ) : bool
intlcal_in_daylight_time ( IntlCalendar $cal ) : bool
public IntlCalendar::isEquivalentTo ( IntlCalendar $other ) : bool
intlcal_is_equivalent_to ( IntlCalendar $cal , IntlCalendar $other ) : bool
public IntlCalendar::isLenient ( void ) : bool
intlcal_is_lenient ( IntlCalendar $cal ) : bool
public IntlCalendar::isSet ( int $field ) : bool
intlcal_is_set ( IntlCalendar $cal , int $field ) : bool
public IntlCalendar::isWeekend ([ float $date = NULL ] ) : bool
intlcal_is_weekend ( IntlCalendar $cal [, float $date = NULL ] ) : bool
public IntlCalendar::roll ( int $field , mixed $amountOrUpOrDown ) : bool
intlcal_roll ( IntlCalendar $cal , int $field , mixed $amountOrUpOrDown ) : bool
public IntlCalendar::set ( int $field , int $value ) : bool
public IntlCalendar::set ( int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool
intlcal_set ( IntlCalendar $cal , int $field , int $value ) : bool
intlcal_set ( IntlCalendar $cal , int $year , int $month [, int $dayOfMonth = NULL [, int $hour = NULL [, int $minute = NULL [, int $second = NULL ]]]] ) : bool
public IntlCalendar::setFirstDayOfWeek ( int $dayOfWeek ) : bool
intlcal_set_first_day_of_week ( IntlCalendar $cal , int $dayOfWeek ) : bool
public IntlCalendar::setLenient ( bool $isLenient ) : bool
intlcal_set_lenient ( IntlCalendar $cal , bool $isLenient ) : bool
public IntlCalendar::setMinimalDaysInFirstWeek ( int $minimalDays ) : bool
intlcal_set_minimal_days_in_first_week ( IntlCalendar $cal , int $minimalDays ) : bool
public IntlCalendar::setRepeatedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_repeated_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public IntlCalendar::setSkippedWallTimeOption ( int $wallTimeOption ) : bool
intlcal_set_skipped_wall_time_option ( IntlCalendar $cal , int $wallTimeOption ) : bool
public IntlCalendar::setTime ( float $date ) : bool
intlcal_set_time ( IntlCalendar $cal , float $date ) : bool
public IntlCalendar::setTimeZone ( mixed $timeZone ) : bool
intlcal_set_time_zone ( IntlCalendar $cal , mixed $timeZone ) : bool
intlcal_to_date_time ( IntlCalendar $cal ) : DateTime
}

IntlGregorianCalendar::__construct

(PHP 5 >= 5.5.0, PHP 7)

IntlGregorianCalendar::__constructCreate the Gregorian Calendar class

Description

public IntlGregorianCalendar::__construct ([ IntlTimeZone $tz [, string $locale ]] )
public IntlGregorianCalendar::__construct ( int $timeZoneOrYear , int $localeOrMonth , int $dayOfMonth )
public IntlGregorianCalendar::__construct ( int $timeZoneOrYear , int $localeOrMonth , int $dayOfMonth , int $hour , int $minute [, int $second ] )

Warning

This function is currently not documented; only its argument list is available.

Parameters

tz

locale

timeZoneOrYear

localeOrMonth

dayOfMonth

hour

minute

second



IntlGregorianCalendar::getGregorianChange

(PHP 5 >= 5.5.0, PHP 7)

IntlGregorianCalendar::getGregorianChangeGet the Gregorian Calendar change date

Description

public IntlGregorianCalendar::getGregorianChange ( void ) : float

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Returns the change date or FALSE on failure.



IntlGregorianCalendar::isLeapYear

(PHP 5 >= 5.5.0, PHP 7)

IntlGregorianCalendar::isLeapYearDetermine if the given year is a leap year

Description

public IntlGregorianCalendar::isLeapYear ( int $year ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

year

Return Values

Returns TRUE for leap years, FALSE otherwise and on failure.



IntlGregorianCalendar::setGregorianChange

(PHP 5 >= 5.5.0, PHP 7)

IntlGregorianCalendar::setGregorianChangeSet the Gregorian Calendar the change date

Description

public IntlGregorianCalendar::setGregorianChange ( float $date ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

date

Return Values

Returns TRUE on success or FALSE on failure.


Table of Contents



The IntlTimeZone class

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

Introduction

Class synopsis

IntlTimeZone {
/* Constants */
const integer DISPLAY_SHORT = 1 ;
const integer DISPLAY_LONG = 2 ;
/* Methods */
public static countEquivalentIDs ( string $zoneId ) : int
public static createDefault ( void ) : IntlTimeZone
public static createEnumeration ([ mixed $countryOrRawOffset ] ) : IntlIterator
public static createTimeZone ( string $zoneId ) : IntlTimeZone
public static createTimeZoneIDEnumeration ( int $zoneType [, string $region [, int $rawOffset ]] ) : IntlIterator
public static fromDateTimeZone ( DateTimeZone $zoneId ) : IntlTimeZone
public static getCanonicalID ( string $zoneId [, bool &$isSystemID ] ) : string
public getDisplayName ([ bool $isDaylight [, int $style [, string $locale ]]] ) : string
public getDSTSavings ( void ) : int
public static getEquivalentID ( string $zoneId , int $index ) : string
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public static getGMT ( void ) : IntlTimeZone
public getID ( void ) : string
public static getIDForWindowsID ( string $timezone [, string $region ] ) : string
public getOffset ( float $date , bool $local , int &$rawOffset , int &$dstOffset ) : int
public getRawOffset ( void ) : int
public static getRegion ( string $zoneId ) : string
public static getTZDataVersion ( void ) : string
public static getUnknown ( void ) : IntlTimeZone
public static getWindowsID ( string $timezone ) : string
public hasSameRules ( IntlTimeZone $otherTimeZone ) : bool
public toDateTimeZone ( void ) : DateTimeZone
public useDaylightTime ( void ) : bool
}

Predefined Constants

IntlTimeZone::DISPLAY_SHORT

IntlTimeZone::DISPLAY_LONG


IntlTimeZone::countEquivalentIDs

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::countEquivalentIDsGet the number of IDs in the equivalency group that includes the given ID

Description

public static IntlTimeZone::countEquivalentIDs ( string $zoneId ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

Return Values



IntlTimeZone::createDefault

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::createDefaultCreate a new copy of the default timezone for this host

Description

public static IntlTimeZone::createDefault ( void ) : IntlTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::createEnumeration

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::createEnumerationGet an enumeration over time zone IDs associated with the given country or offset

Description

public static IntlTimeZone::createEnumeration ([ mixed $countryOrRawOffset ] ) : IntlIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

countryOrRawOffset

Return Values



IntlTimeZone::createTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::createTimeZoneCreate a timezone object for the given ID

Description

public static IntlTimeZone::createTimeZone ( string $zoneId ) : IntlTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

Return Values



IntlTimeZone::createTimeZoneIDEnumeration

(PHP 5 >= 5.5.0, PHP 7)

IntlTimeZone::createTimeZoneIDEnumerationGet an enumeration over system time zone IDs with the given filter conditions

Description

public static IntlTimeZone::createTimeZoneIDEnumeration ( int $zoneType [, string $region [, int $rawOffset ]] ) : IntlIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneType

region

rawOffset

Return Values

Returns IntlIterator or FALSE on failure.



IntlTimeZone::fromDateTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::fromDateTimeZoneCreate a timezone object from DateTimeZone

Description

public static IntlTimeZone::fromDateTimeZone ( DateTimeZone $zoneId ) : IntlTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

Return Values



IntlTimeZone::getCanonicalID

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getCanonicalIDGet the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID

Description

public static IntlTimeZone::getCanonicalID ( string $zoneId [, bool &$isSystemID ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

isSystemID

Return Values



IntlTimeZone::getDisplayName

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getDisplayNameGet a name of this time zone suitable for presentation to the user

Description

public IntlTimeZone::getDisplayName ([ bool $isDaylight [, int $style [, string $locale ]]] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

isDaylight

style

locale

Return Values



IntlTimeZone::getDSTSavings

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getDSTSavingsGet the amount of time to be added to local standard time to get local wall clock time

Description

public IntlTimeZone::getDSTSavings ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getEquivalentID

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getEquivalentIDGet an ID in the equivalency group that includes the given ID

Description

public static IntlTimeZone::getEquivalentID ( string $zoneId , int $index ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

index

Return Values



IntlTimeZone::getErrorCode

intltz_get_error_code

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getErrorCode -- intltz_get_error_codeGet last error code on the object

Description

Object oriented style (method):

public IntlTimeZone::getErrorCode ( void ) : int

Procedural style:

intltz_get_error_code ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getErrorMessage

intltz_get_error_message

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getErrorMessage -- intltz_get_error_messageGet last error message on the object

Description

Object oriented style (method):

public IntlTimeZone::getErrorMessage ( void ) : string

Procedural style:

intltz_get_error_message ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getGMT

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getGMTCreate GMT (UTC) timezone

Description

public static IntlTimeZone::getGMT ( void ) : IntlTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getID

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getIDGet timezone ID

Description

public IntlTimeZone::getID ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getIDForWindowsID

(PHP 7 >= 7.1.0)

IntlTimeZone::getIDForWindowsIDTranslate a Windows timezone into a system timezone

Description

public static IntlTimeZone::getIDForWindowsID ( string $timezone [, string $region ] ) : string

Translates a Windows timezone (e.g. "Pacific Standard Time") into a system timezone (e.g. "America/Los_Angeles").

Note: This function requires ICU version ≥ 52.

Warning

This function is currently not documented; only its argument list is available.

Parameters

timezone

region

Return Values

Returns the system timezone or FALSE on failure.

See Also



IntlTimeZone::getOffset

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getOffsetGet the time zone raw and GMT offset for the given moment in time

Description

public IntlTimeZone::getOffset ( float $date , bool $local , int &$rawOffset , int &$dstOffset ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

date

local

rawOffset

dstOffset

Return Values



IntlTimeZone::getRawOffset

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getRawOffsetGet the raw GMT offset (before taking daylight savings time into account

Description

public IntlTimeZone::getRawOffset ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getRegion

(PHP 5 >= 5.5.0, PHP 7)

IntlTimeZone::getRegionGet the region code associated with the given system time zone ID

Description

public static IntlTimeZone::getRegion ( string $zoneId ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

zoneId

Return Values

Return region or FALSE on failure.



IntlTimeZone::getTZDataVersion

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::getTZDataVersionGet the timezone data version currently used by ICU

Description

public static IntlTimeZone::getTZDataVersion ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::getUnknown

(PHP 5 >= 5.5.0, PHP 7)

IntlTimeZone::getUnknownGet the "unknown" time zone

Description

public static IntlTimeZone::getUnknown ( void ) : IntlTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Returns IntlTimeZone or NULL on failure.



IntlTimeZone::getWindowsID

(PHP 7 >= 7.1.0)

IntlTimeZone::getWindowsIDTranslate a system timezone into a Windows timezone

Description

public static IntlTimeZone::getWindowsID ( string $timezone ) : string

Translates a system timezone (e.g. "America/Los_Angeles") into a Windows timezone (e.g. "Pacific Standard Time").

Note: This function requires ICU version ≥ 52.

Warning

This function is currently not documented; only its argument list is available.

Parameters

timezone

Return Values

Returns the Windows timezone or FALSE on failure.

See Also



IntlTimeZone::hasSameRules

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::hasSameRulesCheck if this zone has the same rules and offset as another zone

Description

public IntlTimeZone::hasSameRules ( IntlTimeZone $otherTimeZone ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

otherTimeZone

Return Values



IntlTimeZone::toDateTimeZone

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::toDateTimeZoneConvert to DateTimeZone object

Description

public IntlTimeZone::toDateTimeZone ( void ) : DateTimeZone

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlTimeZone::useDaylightTime

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

IntlTimeZone::useDaylightTimeCheck if this time zone uses daylight savings time

Description

public IntlTimeZone::useDaylightTime ( void ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values


Table of Contents



The IntlDateFormatter class

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

Introduction

Date Formatter is a concrete class that enables locale-dependent formatting/parsing of dates using pattern strings and/or canned patterns.

This class represents the ICU date formatting functionality. It allows users to display dates in a localized format or to parse strings into PHP date values using pattern strings and/or canned patterns.

Class synopsis

IntlDateFormatter {
/* Methods */
public __construct ( string $locale , int $datetype , int $timetype [, mixed $timezone = NULL [, mixed $calendar = NULL [, string $pattern = "" ]]] )
public static create ( string $locale , int $datetype , int $timetype [, mixed $timezone = NULL [, mixed $calendar = NULL [, string $pattern = "" ]]] ) : IntlDateFormatter
public format ( mixed $value ) : string
public static formatObject ( object $object [, mixed $format = NULL [, string $locale = NULL ]] ) : string
public getCalendar ( void ) : int
public getDateType ( void ) : int
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getLocale ([ int $which ] ) : string
public getPattern ( void ) : string
public getTimeType ( void ) : int
public getTimeZoneId ( void ) : string
public getCalendarObject ( void ) : IntlCalendar
public getTimeZone ( void ) : IntlTimeZone
public isLenient ( void ) : bool
public localtime ( string $value [, int &$position ] ) : array
public parse ( string $value [, int &$position ] ) : int
public setCalendar ( mixed $which ) : bool
public setLenient ( bool $lenient ) : bool
public setPattern ( string $pattern ) : bool
public setTimeZoneId ( string $zone ) : bool
public setTimeZone ( mixed $zone ) : bool
}

Predefined Constants

These constants are used to specify different formats in the constructor for DateType and TimeType.

IntlDateFormatter::NONE (integer)
Do not include this element
IntlDateFormatter::FULL (integer)
Completely specified style (Tuesday, April 12, 1952 AD or 3:30:42pm PST)
IntlDateFormatter::LONG (integer)
Long style (January 12, 1952 or 3:30:32pm)
IntlDateFormatter::MEDIUM (integer)
Medium style (Jan 12, 1952)
IntlDateFormatter::SHORT (integer)
Most abbreviated style, only essential data (12/13/52 or 3:30pm)

The following int constants are used to specify the calendar. These calendars are all based directly on the Gregorian calendar. Non-Gregorian calendars need to be specified in locale. Examples might include locale="hi@calendar=BUDDHIST".

IntlDateFormatter::TRADITIONAL (integer)
Non-Gregorian Calendar
IntlDateFormatter::GREGORIAN (integer)
Gregorian Calendar


IntlDateFormatter::create

datefmt_create

IntlDateFormatter::__construct

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::create -- datefmt_create -- IntlDateFormatter::__constructCreate a date formatter

Description

Object oriented style

public static IntlDateFormatter::create ( string $locale , int $datetype , int $timetype [, mixed $timezone = NULL [, mixed $calendar = NULL [, string $pattern = "" ]]] ) : IntlDateFormatter

Object oriented style (constructor)

public IntlDateFormatter::__construct ( string $locale , int $datetype , int $timetype [, mixed $timezone = NULL [, mixed $calendar = NULL [, string $pattern = "" ]]] )

Procedural style

datefmt_create ( string $locale , int $datetype , int $timetype [, mixed $timezone = NULL [, mixed $calendar = NULL [, string $pattern = "" ]]] ) : IntlDateFormatter

Create a date formatter.

Parameters

locale

Locale to use when formatting or parsing or NULL to use the value specified in the ini setting intl.default_locale.

datetype

Date type to use (none, short, medium, long, full). This is one of the IntlDateFormatter constants. It can also be NULL, in which case ICUʼs default date type will be used.

timetype

Time type to use (none, short, medium, long, full). This is one of the IntlDateFormatter constants. It can also be NULL, in which case ICUʼs default time type will be used.

timezone

Time zone ID. The default (and the one used if NULL is given) is the one returned by date_default_timezone_get() or, if applicable, that of the IntlCalendar object passed for the calendar parameter. This ID must be a valid identifier on ICUʼs database or an ID representing an explicit offset, such as GMT-05:30.

This can also be an IntlTimeZone or a DateTimeZone object.

calendar

Calendar to use for formatting or parsing. The default value is NULL, which corresponds to IntlDateFormatter::GREGORIAN. This can either be one of the IntlDateFormatter calendar constants or an IntlCalendar. Any IntlCalendar object passed will be clone; it will not be changed by the IntlDateFormatter. This will determine the calendar type used (gregorian, islamic, persian, etc.) and, if NULL is given for the timezone parameter, also the timezone used.

pattern

Optional pattern to use when formatting or parsing. Possible patterns are documented at » http://userguide.icu-project.org/formatparse/datetime.

Return Values

The created IntlDateFormatter or FALSE in case of failure.

Changelog

Version Description
5.5.0/PECL 3.0.0

An IntlCalendar object is allowed for calendar.

Objects of type IntlTimeZone and DateTimeZone are allowed for timezone.

Invalid timezone identifiers (including empty strings) are no longer allowed for timezone.

If NULL is given for timezone, the timezone identifier given by date_default_timezone_get() will be used instead of ICUʼs default.

Examples

Example #1 datefmt_create() example

<?php
$fmt 
datefmt_create"en_US" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
    
'America/Los_Angeles'IntlDateFormatter::GREGORIAN  );
echo 
"First Formatted output is ".datefmt_format$fmt 0);
$fmt datefmt_create"de-DE" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
    
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo 
"Second Formatted output is ".datefmt_format$fmt 0);

$fmt datefmt_create"en_US" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
     
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  ,"MM/dd/yyyy");
echo 
"First Formatted output with pattern is ".datefmt_format$fmt 0);
$fmt datefmt_create"de-DE" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
     
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  ,"MM/dd/yyyy");
echo 
"Second Formatted output with pattern is ".datefmt_format$fmt 0);
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter"en_US" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
    
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo 
"First Formatted output is ".$fmt->format(0);
$fmt = new IntlDateFormatter"de-DE" ,IntlDateFormatter::FULLIntlDateFormatter::FULL
    
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo 
"Second Formatted output is ".$fmt->format(0);

$fmt = new IntlDateFormatter"en_US" ,IntlDateFormatter::FULLIntlDateFormatter::FULL
     
'America/Los_Angeles',IntlDateFormatter::GREGORIAN  ,"MM/dd/yyyy");
echo 
"First Formatted output with pattern is ".$fmt->format(0);
$fmt = new IntlDateFormatter"de-DE" ,IntlDateFormatter::FULLIntlDateFormatter::FULL,
      
'America/Los_Angeles',IntlDateFormatter::GREGORIAN "MM/dd/yyyy");
echo 
"Second Formatted output with pattern is ".$fmt->format(0);
?>

The above example will output:

   First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
   Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
   First Formatted output with pattern is 12/31/1969
   Second Formatted output with pattern is 12/31/1969
            

See Also



IntlDateFormatter::format

datefmt_format

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::format -- datefmt_formatFormat the date/time value as a string

Description

Object oriented style

public IntlDateFormatter::format ( mixed $value ) : string

Procedural style

datefmt_format ( IntlDateFormatter $fmt , mixed $value ) : string

Formats the time value as a string.

Parameters

fmt

The date formatter resource.

value

Value to format. This may be a DateTimeInterface object, an IntlCalendar object, a numeric type representing a (possibly fractional) number of seconds since epoch or an array in the format output by localtime().

If a DateTime or an IntlCalendar object is passed, its timezone is not considered. The object will be formatted using the formaterʼs configured timezone. If one wants to use the timezone of the object to be formatted, IntlDateFormatter::setTimeZone() must be called before with the objectʼs timezone. Alternatively, the static function IntlDateFormatter::formatObject() may be used instead.

Return Values

The formatted string or, if an error occurred, FALSE.

Changelog

Version Description
7.1.5 Support for providing general DateTimeInterface objects to the value parameter was added. Formerly, only proper DateTime objects were supported.
5.5.0/PECL 3.0.0 Support for providing IntlCalendar objects to the value parameter was added.
5.3.4 Support for providing DateTime objects to the value parameter was added.

Examples

Example #1 datefmt_format() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'First Formatted output is ' datefmt_format($fmt0);

$fmt datefmt_create(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Second Formatted output is ' datefmt_format($fmt0);

$fmt datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'First Formatted output with pattern is ' datefmt_format($fmt0);

$fmt datefmt_create(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
"Second Formatted output with pattern is " datefmt_format($fmt0);
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'First Formatted output is ' $fmt->format(0);

$fmt = new IntlDateFormatter(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Second Formatted output is ' $fmt->format(0);

$fmt = new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'First Formatted output with pattern is ' $fmt->format(0);

$fmt = new IntlDateFormatter(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'Second Formatted output with pattern is ' $fmt->format(0);
?>

The above example will output:

   First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
   Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
   First Formatted output with pattern is 12/31/1969
   Second Formatted output with pattern is 12/31/1969
   

Example #3 With IntlCalendar object

<?php
$tz 
reset(iterator_to_array(IntlTimeZone::createEnumeration('FR')));
$formatter IntlDateFormatter::create(
    
'fr_FR',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
$tz,
    
IntlDateFormatter::GREGORIAN
);

$cal IntlCalendar::createInstance($tz'@calendar=islamic-civil');
$cal->set(IntlCalendar::FIELD_MONTH8); //9th month, Ramadan
$cal->set(IntlCalendar::FIELD_DAY_OF_MONTH1); //1st day
$cal->clear(IntlCalendar::FIELD_HOUR_OF_DAY);
$cal->clear(IntlCalendar::FIELD_MINUTE);
$cal->clear(IntlCalendar::FIELD_SECOND);
$cal->clear(IntlCalendar::FIELD_MILLISECOND);

echo 
"In this islamic year, Ramadan started/will start on:\n\t",
        
$formatter->format($cal), "\n";

//Itʼs the formatterʼs timezone that is used:
$formatter->setTimeZone('Asia/Tokyo');
echo 
"After changing timezone:\n\t",
        
$formatter->format($cal), "\n";

The above example will output:

   In this islamic year, Ramadan started/will start on:
       mardi 9 juillet 2013 19:00:00 heure avancée d’Europe centrale
   After changing timezone:
       mercredi 10 juillet 2013 02:00:00 heure normale du Japon
   
   

See Also



IntlDateFormatter::formatObject

datefmt_format_object

(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)

IntlDateFormatter::formatObject -- datefmt_format_objectFormats an object

Description

Object oriented style

public static IntlDateFormatter::formatObject ( object $object [, mixed $format = NULL [, string $locale = NULL ]] ) : string

Procedural style

public static datefmt_format_object ( object $object [, mixed $format = NULL [, string $locale = NULL ]] ) : string

This function allows formatting an IntlCalendar or DateTime object without first explicitly creating a IntlDateFormatter object.

The temporary IntlDateFormatter that will be created will take the timezone from the passed in object. The timezone database bundled with PHP will not be used – ICU's will be used instead. The timezone identifier used in DateTime objects must therefore also exist in ICU's database.

Parameters

object

An object of type IntlCalendar or DateTime. The timezone information in the object will be used.

format

How to format the date/time. This can either be an array with two elements (first the date style, then the time style, these being one of the constants IntlDateFormatter::NONE, IntlDateFormatter::SHORT, IntlDateFormatter::MEDIUM, IntlDateFormatter::LONG, IntlDateFormatter::FULL), an integer with the value of one of these constants (in which case it will be used both for the time and the date) or a string with the format described in » the ICU documentation. If NULL, the default style will be used.

locale

The locale to use, or NULL to use the default one.

Return Values

A string with result or FALSE on failure.

Examples

Example #1 IntlDateFormatter::formatObject() examples

<?php
/* default timezone is irrelevant; timezone taken from the object */
ini_set('date.timezone''UTC');
/* default locale is taken from this ini setting */
ini_set('intl.default_locale''fr_FR');

$cal IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
echo 
"default:\n\t",
        
IntlDateFormatter::formatObject($cal),
        
"\n";

echo 
"long \$format (full):\n\t",
        
IntlDateFormatter::formatObject($calIntlDateFormatter::FULL),
        
"\n";

echo 
"array \$format (none, full):\n\t",
        
IntlDateFormatter::formatObject($cal, array(
                
IntlDateFormatter::NONE,
                
IntlDateFormatter::FULL)),
        
"\n";

echo 
"string \$format (d 'of' MMMM y):\n\t",
        
IntlDateFormatter::formatObject($cal"d 'of' MMMM y"'en_US'),
        
"\n";

echo 
"with DateTime:\n\t",
        
IntlDateFormatter::formatObject(
                new 
DateTime("2013-09-09 09:09:09 Europe/Madrid"),
                
IntlDateFormatter::FULL,
                
'es_ES'),
        
"\n";

The above example will output:

   default:
       6 juin 2013 17:05:06
   long $format (full):
       jeudi 6 juin 2013 17:05:06 heure d’été irlandaise
   array $format (none, full):
       17:05:06 heure d’été irlandaise
   string $format (d 'of' MMMM y):
       6 of June 2013
   with DateTime:
       lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
   
   



IntlDateFormatter::getCalendar

datefmt_get_calendar

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getCalendar -- datefmt_get_calendarGet the calendar type used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::getCalendar ( void ) : int

Procedural style

datefmt_get_calendar ( IntlDateFormatter $fmt ) : int

Parameters

fmt

The formatter resource

Return Values

The calendar type being used by the formatter. Either IntlDateFormatter::TRADITIONAL or IntlDateFormatter::GREGORIAN.

Examples

Example #1 datefmt_get_calendar() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'calendar of the formatter is : ' datefmt_get_calendar($fmt);
datefmt_set_calendar($fmtIntlDateFormatter::TRADITIONAL);
echo 
'Now calendar of the formatter is : ' datefmt_get_calendar($fmt);
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'calendar of the formatter is : ' $fmt->getCalendar();
$fmt->setCalendar(IntlDateFormatter::TRADITIONAL);
echo 
'Now calendar of the formatter is : ' $fmt->getCalendar();

?>

The above example will output:

   calendar of the formatter is : 1
   Now calendar of the formatter is : 0
   

See Also



IntlDateFormatter::getDateType

datefmt_get_datetype

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getDateType -- datefmt_get_datetypeGet the datetype used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::getDateType ( void ) : int

Procedural style

datefmt_get_datetype ( IntlDateFormatter $fmt ) : int

Returns date type used by the formatter.

Parameters

fmt

The formatter resource.

Return Values

The current date type value of the formatter.

Examples

Example #1 datefmt_get_datetype() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'datetype of the formatter is : ' datefmt_get_datetype($fmt);
echo 
'First Formatted output with datetype is ' datefmt_format($fmt0);

$fmt datefmt_create(
    
'en_US',
    
IntlDateFormatter::SHORT,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Now datetype of the formatter is : ' datefmt_get_datetype($fmt);
echo 
'Second Formatted output with datetype is ' datefmt_format($fmt0);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'datetype of the formatter is : ' $fmt->getDateType();
echo 
'First Formatted output is ' $fmt->format(0);
$fmt = new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::SHORT,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Now datetype of the formatter is : ' $fmt->getDateType();
echo 
'Second Formatted output is ' $fmt->format(0);

?>

The above example will output:

   datetype of the formatter is : 0
   First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
   Now datetype of the formatter is : 2
   Second Formatted output is 12/31/69 4:00:00 PM PT
   

See Also



IntlDateFormatter::getErrorCode

datefmt_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getErrorCode -- datefmt_get_error_codeGet the error code from last operation

Description

Object oriented style

public IntlDateFormatter::getErrorCode ( void ) : int

Procedural style

datefmt_get_error_code ( IntlDateFormatter $fmt ) : int

Get the error code from last operation. Returns error code from the last number formatting operation.

Parameters

fmt

The formatter resource.

Return Values

The error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.

Examples

Example #1 datefmt_get_error_code() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str datefmt_format($fmt);
if (!
$str) {
    
printf(
        
"ERROR: %s (%d)\n",
        
datefmt_get_error_message($fmt),
        
datefmt_get_error_code($fmt)
    );
}
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str $fmt->format();
if (!
$str) {
    
printf(
        
"ERROR: %s (%d)\n",
        
$fmt->getErrorMessage(),
        
$fmt->getErrorCode()
    );
}
?>

The above example will output:

   ERROR: U_ZERO_ERROR (0)
   

See Also



IntlDateFormatter::getErrorMessage

datefmt_get_error_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getErrorMessage -- datefmt_get_error_messageGet the error text from the last operation

Description

Object oriented style

public IntlDateFormatter::getErrorMessage ( void ) : string

Procedural style

datefmt_get_error_message ( IntlDateFormatter $fmt ) : string

Get the error text from the last operation.

Parameters

fmt

The formatter resource.

Return Values

Description of the last error.

Examples

Example #1 datefmt_get_error_message() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str datefmt_format($fmt);
if (!
$str) {
    
printf(
        
"ERROR: %s (%d)\n",
        
datefmt_get_error_message($fmt),
        
datefmt_get_error_code($fmt)
    );
}
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str $fmt->format();
if(!
$str) {
    
printf(
        
"ERROR: %s (%d)\n",
        
$fmt->getErrorMessage(),
        
$fmt->getErrorCode()
    );
}

?>

The above example will output:

   ERROR: U_ZERO_ERROR (0)
   

See Also



IntlDateFormatter::getLocale

datefmt_get_locale

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getLocale -- datefmt_get_localeGet the locale used by formatter

Description

Object oriented style

public IntlDateFormatter::getLocale ([ int $which ] ) : string

Procedural style

datefmt_get_locale ( IntlDateFormatter $fmt [, int $which ] ) : string

Get locale used by the formatter.

Parameters

fmt

The formatter resource

hich

You can choose between valid and actual locale ( Locale::VALID_LOCALE, Locale::ACTUAL_LOCALE, respectively). The default is the actual locale.

Return Values

the locale of this formatter or 'false' if error

Examples

Example #1 datefmt_get_locale() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'locale of the formatter is : " . datefmt_get_locale($fmt);
echo '
First Formatted output is " . datefmt_format($fmt, 0);

$fmt = datefmt_create(
    'de-DE',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'America/Los_Angeles',
    IntlDateFormatter::GREGORIAN
);
echo 'locale of the formatter is : ' . datefmt_get_locale(
$fmt);
echo 'Second Formatted output is ' . datefmt_format(
$fmt, 0);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'locale of the formatter is : ' $fmt->getLocale();
echo 
'First Formatted output is ' $fmt->format(0);

$fmt = new IntlDateFormatter(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'locale of the formatter is : ' $fmt->getLocale();
echo 
'Second Formatted output is ' $fmt->format(0);

?>

The above example will output:

   locale of the formatter is : en
   First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
   locale of the formatter is : de
   Second Formatted output is Mittwoch, 31. Dezember 1969 16:00 Uhr GMT-08:00
   

See Also



IntlDateFormatter::getPattern

datefmt_get_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getPattern -- datefmt_get_patternGet the pattern used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::getPattern ( void ) : string

Procedural style

datefmt_get_pattern ( IntlDateFormatter $fmt ) : string

Get pattern used by the formatter.

Parameters

fmt

The formatter resource.

Return Values

The pattern string being used to format/parse.

Examples

Example #1 datefmt_get_pattern() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'pattern of the formatter is : ' datefmt_get_pattern($fmt);
echo 
'First Formatted output with pattern is ' datefmt_format($fmt0);
datefmt_set_pattern($fmt,'yyyymmdd hh:mm:ss z');
echo 
'Now pattern of the formatter is : ' datefmt_get_pattern($fmt);
echo 
'Second Formatted output with pattern is ' datefmt_format($fmt0);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'pattern of the formatter is : ' $fmt->getPattern();
echo 
'First Formatted output is ' $fmt->format(0);
$fmt->setPattern('yyyymmdd hh:mm:ss z');
echo 
'Now pattern of the formatter is : ' $fmt->getPattern();
echo 
'Second Formatted output is ' $fmt->format(0);
?>

The above example will output:

   pattern of the formatter is : MM/dd/yyyy
   First Formatted output is 12/31/1969
   Now pattern of the formatter is : yyyymmdd hh:mm:ss z
   Second Formatted output is 19690031 04:00:00 PST
   

See Also



IntlDateFormatter::getTimeType

datefmt_get_timetype

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getTimeType -- datefmt_get_timetypeGet the timetype used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::getTimeType ( void ) : int

Procedural style

datefmt_get_timetype ( IntlDateFormatter $fmt ) : int

Return time type used by the formatter.

Parameters

fmt

The formatter resource.

Return Values

The current date type value of the formatter.

Examples

Example #1 datefmt_get_timetype() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timetype of the formatter is : ' datefmt_get_timetype($fmt);
echo 
'First Formatted output with timetype is ' datefmt_format($fmt0);

$fmt datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::SHORT,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Now timetype of the formatter is : ' datefmt_get_timetype($fmt);
echo 
'Second Formatted output with timetype is ' datefmt_format($fmt0);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timetype of the formatter is : ' $fmt->getTimeType();
echo 
'First Formatted output is ' $fmt->format(0);

$fmt = new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::SHORT,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Now timetype of the formatter is : ' $fmt->getTimeType();
echo 
'Second Formatted output is ' $fmt->format(0);

?>

The above example will output:

   timetype of the formatter is : 0
   First Formatted output is Wednesday, December 31, 1969 4:00:00 PM PT
   Now timetype of the formatter is : 3
   Second Formatted output is Wednesday, December 31, 1969 4:00 PM
   

See Also



IntlDateFormatter::getTimeZoneId

datefmt_get_timezone_id

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getTimeZoneId -- datefmt_get_timezone_idGet the timezone-id used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::getTimeZoneId ( void ) : string

Procedural style

datefmt_get_timezone_id ( IntlDateFormatter $fmt ) : string

Get the timezone-id used for the IntlDateFormatter.

Parameters

fmt

The formatter resource.

Return Values

ID string for the time zone used by this formatter.

Examples

Example #1 datefmt_get_timezone_id() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timezone_id of the formatter is : ' datefmt_get_timezone_id($fmt);
datefmt_set_timezone_id($fmt'CN');
echo 
'Now timezone_id of the formatter is : ' datefmt_get_timezone_id($fmt);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timezone_id of the formatter is : ' $fmt->getTimezoneId();
$fmt->setTimezoneId('CN');
echo 
'Now timezone_id of the formatter is : ' $fmt->getTimezoneId();

?>

The above example will output:

   timezone_id of the formatter is : America/Los_Angeles
   Now timezone_id of the formatter is : CN
   

See Also



IntlDateFormatter::getCalendarObject

datefmt_get_calendar_object

(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)

IntlDateFormatter::getCalendarObject -- datefmt_get_calendar_objectGet copy of formatterʼs calendar object

Description

Object oriented style

public IntlDateFormatter::getCalendarObject ( void ) : IntlCalendar

Procedural style

datefmt_get_calendar_object ( void ) : IntlCalendar

Obtain a copy of the calendar object used internally by this formatter. This calendar will have a type (as in gregorian, japanese, buddhist, roc, persian, islamic, etc.) and a timezone that match the type and timezone used by the formatter. The date/time of the object is unspecified.

Parameters

This function has no parameters.

Return Values

A copy of the internal calendar object used by this formatter.

Examples

Example #1 IntlDateFormatter::getCalendarObject() example

<?php
$formatter 
IntlDateFormatter::create(
    
"fr_FR@calendar=islamic"
    
NULL,
    
NULL,
    
"GMT-01:00",
    
IntlDateFormatter::TRADITIONAL
);

$cal $formatter->getCalendarObject();

var_dump(
    
$cal->getType(),
    
$cal->getTimeZone(),
    
$cal->getLocale(Locale::VALID_LOCALE)
);

The above example will output:

   string(7) "islamic"
   object(IntlTimeZone)#3 (4) {
     ["valid"]=>
     bool(true)
     ["id"]=>
     string(9) "GMT-01:00"
     ["rawOffset"]=>
     int(-3600000)
     ["currentOffset"]=>
     int(-3600000)
   }
   string(5) "fr_FR"
   

See Also



IntlDateFormatter::getTimeZone

datefmt_get_timezone

(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)

IntlDateFormatter::getTimeZone -- datefmt_get_timezoneGet formatterʼs timezone

Description

Object oriented style

public IntlDateFormatter::getTimeZone ( void ) : IntlTimeZone

Procedural style

datefmt_get_timezone ( void ) : IntlTimeZone

Returns an IntlTimeZone object representing the timezone that will be used by this object to format dates and times. When formatting IntlCalendar and DateTime objects with this IntlDateFormatter, the timezone used will be the one returned by this method, not the one associated with the objects being formatted.

Parameters

This function has no parameters.

Return Values

The associated IntlTimeZone object or FALSE on failure.

Examples

Example #1 IntlDateFormatter::getTimeZone() examples

<?php

$madrid 
IntlDateFormatter::create(NULLNULLNULL'Europe/Madrid');
$lisbon IntlDateFormatter::create(NULLNULLNULL'Europe/Lisbon');

var_dump($madrid->getTimezone());
echo 
$madrid->getTimezone()->getDisplayName(
        
falseIntlTimeZone::DISPLAY_GENERIC_LOCATION"en_US"), "\n";
echo 
$lisbon->getTimeZone()->getId(), "\n";
//The id can also be retrieved with ->getTimezoneId()
echo $lisbon->getTimeZoneId(), "\n";

The above example will output:

   object(IntlTimeZone)#4 (4) {
     ["valid"]=>
     bool(true)
     ["id"]=>
     string(13) "Europe/Madrid"
     ["rawOffset"]=>
     int(3600000)
     ["currentOffset"]=>
     int(7200000)
   }
   Spain Time
   Europe/Lisbon
   Europe/Lisbon
   
   

See Also



IntlDateFormatter::isLenient

datefmt_is_lenient

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::isLenient -- datefmt_is_lenientGet the lenient used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::isLenient ( void ) : bool

Procedural style

datefmt_is_lenient ( IntlDateFormatter $fmt ) : bool

Check if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly.

Parameters

fmt

The formatter resource.

Return Values

TRUE if parser is lenient, FALSE if parser is strict. By default the parser is lenient.

Examples

Example #1 datefmt_is_lenient() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'dd/mm/yyyy'
);
echo 
'lenient of the formatter is : ';
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
datefmt_parse($fmt'35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " datefmt_parse($fmt'35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}
datefmt_set_lenient($fmt,false);
echo 
'Now lenient of the formatter is : ';
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
datefmt_parse($fmt'35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').Result is : " datefmt_parse($fmt'35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
"dd/mm/yyyy"
);
echo 
"lenient of the formatter is : ";
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
$fmt->parse('35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " $fmt->parse('35/13/1971');
if (
intl_get_error_code() != 0){
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}

$fmt->setLenient(FALSE);
echo 
'Now lenient of the formatter is : ';
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
$fmt->parse('35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " $fmt->parse('35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}

?>

The above example will output:

   lenient of the formatter is : TRUE
   Trying to do parse('35/13/1971').
   Result is : -2147483
   Now lenient of the formatter is : FALSE
   Trying to do parse('35/13/1971').
   Result is : 
   Error_msg is : Date parsing failed: U_PARSE_ERROR 
   Error_code is : 9
   

See Also



IntlDateFormatter::localtime

datefmt_localtime

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::localtime -- datefmt_localtimeParse string to a field-based time value

Description

Object oriented style

public IntlDateFormatter::localtime ( string $value [, int &$position ] ) : array

Procedural style

datefmt_localtime ( IntlDateFormatter $fmt , string $value [, int &$position ] ) : array

Converts string $value to a field-based time value ( an array of various fields), starting at $parse_pos and consuming as much of the input value as possible.

Parameters

fmt

The formatter resource

value

string to convert to a time

position

Position at which to start the parsing in $value (zero-based). If no error occurs before $value is consumed, $parse_pos will contain -1 otherwise it will contain the position at which parsing ended . If $parse_pos > strlen($value), the parse fails immediately.

Return Values

Localtime compatible array of integers : contains 24 hour clock value in tm_hour field

Examples

Example #1 datefmt_localtime() example

<?php

$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$arr datefmt_localtime($fmt'Wednesday, December 31, 1969 4:00:00 PM PT'0);
echo 
'First parsed output is ';
if (
$arr) {
    foreach (
$arr as $key => $value) {
        echo 
"$key : $value , ";
    }
}

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$arr $fmt->localtime('Wednesday, December 31, 1969 4:00:00 PM PT'0);
echo 
'First parsed output is ';
if (
$arr) {
    foreach (
$arr as $key => $value) {
        echo 
"$key : $value , ";
    }
}

?>

The above example will output:

   First parsed output is tm_sec : 0 , tm_min : 0 , tm_hour : 16 , tm_year : 1969 , 
   tm_mday : 31 , tm_wday : 4 , tm_yday : 365 , tm_mon : 11 , tm_isdst : 0 , 
   

See Also



IntlDateFormatter::parse

datefmt_parse

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::parse -- datefmt_parseParse string to a timestamp value

Description

Object oriented style

public IntlDateFormatter::parse ( string $value [, int &$position ] ) : int

Procedural style

datefmt_parse ( IntlDateFormatter $fmt , string $value [, int &$position ] ) : int

Converts string $value to an incremental time value, starting at $parse_pos and consuming as much of the input value as possible.

Parameters

fmt

The formatter resource

value

string to convert to a time

position

Position at which to start the parsing in $value (zero-based). If no error occurs before $value is consumed, $parse_pos will contain -1 otherwise it will contain the position at which parsing ended (and the error occurred). This variable will contain the end position if the parse fails. If $parse_pos > strlen($value), the parse fails immediately.

Return Values

timestamp parsed value, or FALSE if value can't be parsed.

Examples

Example #1 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'First parsed output is ' $fmt->parse('Wednesday, December 20, 1989 4:00:00 PM PT');
$fmt = new IntlDateFormatter(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
?>

Example #2 datefmt_parse() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'First parsed output is ' datefmt_parse($fmt'Wednesday, December 20, 1989 4:00:00 PM PT');
$fmt datefmt_create(
    
'de-DE',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'Second parsed output is ' datefmt_parse($fmt'Mittwoch, 20. Dezember 1989 16:00 Uhr GMT-08:00');
?

The above example will output:

   First parsed output is 630201600
   Second parsed output is 630201600
   

See Also



IntlDateFormatter::setCalendar

datefmt_set_calendar

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::setCalendar -- datefmt_set_calendarSets the calendar type used by the formatter

Description

Object oriented style

public IntlDateFormatter::setCalendar ( mixed $which ) : bool

Procedural style

datefmt_set_calendar ( IntlDateFormatter $fmt , mixed $which ) : bool

Sets the calendar or calendar type used by the formatter.

Parameters

fmt

The formatter resource.

which

This can either be: the calendar type to use (default is IntlDateFormatter::GREGORIAN, which is also used if NULL is specified) or an IntlCalendar object.

Any IntlCalendar object passed in will be cloned; no modifications will be made to the argument object.

The timezone of the formatter will only be kept if an IntlCalendar object is not passed, otherwise the new timezone will be that of the passed object.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
5.5.0/PECL 3.0.0 It became possible to pass an IntlCalendar object.

Examples

Example #1 datefmt_set_calendar() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'calendar of the formatter is : ' datefmt_get_calendar($fmt);
datefmt_set_calendar($fmtIntlDateFormatter::TRADITIONAL);
echo 
'Now calendar of the formatter is : ' datefmt_get_calendar($fmt);
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN  
);
echo 
'calendar of the formatter is : ' $fmt->getCalendar();
$fmt->setCalendar(IntlDateFormatter::TRADITIONAL);
echo 
'Now calendar of the formatter is : ' $fmt->getCalendar();
?>

The above example will output:

   calendar of the formatter is : 1
   Now calendar of the formatter is : 0
   

Example #3 Example with IntlCalendar argument

<?php
$time 
strtotime("2013-03-03 00:00:00 UTC");
$formatter IntlDateFormatter::create("en_US"NULLNULL"Europe/Amsterdam");

echo 
"before: "$formatter->format($time), "\n";

/* note that the calendar's locale is not used! */
$formatter->setCalendar(IntlCalendar::createInstance(
               
"America/New_York""pt_PT@calendar=islamic"));

echo 
"after:  "$formatter->format($time), "\n";

The above example will output:

   before: Sunday, March 3, 2013 at 1:00:00 AM Central European Standard Time
   after:  Saturday, Rabiʻ II 20, 1434 at 7:00:00 PM Eastern Standard Time
   
   

See Also



IntlDateFormatter::setLenient

datefmt_set_lenient

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::setLenient -- datefmt_set_lenientSet the leniency of the parser

Description

Object oriented style

public IntlDateFormatter::setLenient ( bool $lenient ) : bool

Procedural style

datefmt_set_lenient ( IntlDateFormatter $fmt , bool $lenient ) : bool

Define if the parser is strict or lenient in interpreting inputs that do not match the pattern exactly. Enabling lenient parsing allows the parser to accept otherwise flawed date or time patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or invalid values ("February 30th") are not accepted.

Parameters

fmt

The formatter resource

lenient

Sets whether the parser is lenient or not, default is TRUE (lenient).

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 datefmt_set_lenient() example

<?php
$fmt 
datefmt_create(
    
'en_US'
    
IntlDateFormatter::FULL
    
IntlDateFormatter::FULL
    
'America/Los_Angeles'
    
IntlDateFormatter::GREGORIAN
    
'dd/MM/yyyy'
);
echo 
'lenient of the formatter is : ';
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
datefmt_parse($fmt'35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " datefmt_parse($fmt'35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}
datefmt_set_lenient($fmtfalse);
echo 
"\nNow lenient of the formatter is : ";
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
datefmt_parse($fmt'35/13/1971');
echo 
"\nTrying to do parse('35/13/1971').\nResult is : " datefmt_parse($fmt'35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : ".intl_get_error_message();
    echo 
"\nError_code is : ".intl_get_error_code();
}

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'dd/MM/yyyy'
);
echo 
'lenient of the formatter is : ';
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
$fmt->parse('35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " $fmt->parse('35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}

$fmt->setLenient(FALSE);
echo 
"\nNow lenient of the formatter is : ";
if (
$fmt->isLenient()) {
    echo 
'TRUE';
} else {
    echo 
'FALSE';
}
$fmt->parse('35/13/1971');
echo 
"\n Trying to do parse('35/13/1971').\nResult is : " $fmt->parse('35/13/1971');
if (
intl_get_error_code() != 0) {
    echo 
"\nError_msg is : " intl_get_error_message();
    echo 
"\nError_code is : " intl_get_error_code();
}

?>

The above example will output:

   lenient of the formatter is : TRUE
   Trying to do parse('35/13/1971').
   Result is : 66038400
   Now lenient of the formatter is : FALSE
   Trying to do parse('35/13/1971').
   Result is : 
   Error_msg is : Date parsing failed: U_PARSE_ERROR
   Error_code is : 9
   
   

See Also



IntlDateFormatter::setPattern

datefmt_set_pattern

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::setPattern -- datefmt_set_patternSet the pattern used for the IntlDateFormatter

Description

Object oriented style

public IntlDateFormatter::setPattern ( string $pattern ) : bool

Procedural style

datefmt_set_pattern ( IntlDateFormatter $fmt , string $pattern ) : bool

Set the pattern used for the IntlDateFormatter.

Parameters

fmt

The formatter resource.

pattern

New pattern string to use. Possible patterns are documented at » http://userguide.icu-project.org/formatparse/datetime.

Return Values

Returns TRUE on success or FALSE on failure. Bad formatstrings are usually the cause of the failure.

Examples

Example #1 datefmt_set_pattern() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'pattern of the formatter is : ' datefmt_get_pattern($fmt);
echo 
'First Formatted output with pattern is ' datefmt_format($fmt0);
datefmt_set_pattern($fmt'yyyymmdd hh:mm:ss z');
echo 
'Now pattern of the formatter is : ' datefmt_get_pattern($fmt);
echo 
'Second Formatted output with pattern is ' datefmt_format($fmt0);

?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN,
    
'MM/dd/yyyy'
);
echo 
'pattern of the formatter is : ' $fmt->getPattern();
echo 
'First Formatted output is ' $fmt->format(0);
$fmt->setPattern('yyyymmdd hh:mm:ss z');
echo 
'Now pattern of the formatter is : ' $fmt->getPattern();
echo 
'Second Formatted output is ' $fmt->format(0);

?>

The above example will output:

   pattern of the formatter is : MM/dd/yyyy
   First Formatted output with pattern is 12/31/1969
   Now pattern of the formatter is : yyyymmdd hh:mm:ss z
   Second Formatted output with pattern is 19690031 04:00:00 PST
   

See Also



IntlDateFormatter::setTimeZoneId

datefmt_set_timezone_id

(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)

IntlDateFormatter::setTimeZoneId -- datefmt_set_timezone_idSets the time zone to use

Warning

This function was DEPRECATED in PHP 5.5.0, and REMOVED in PHP 7.0.0.

Alternatives to this function include:

Description

Object oriented style

public IntlDateFormatter::setTimeZoneId ( string $zone ) : bool

Procedural style

datefmt_set_timezone_id ( IntlDateFormatter $fmt , string $zone ) : bool

Sets the time zone to use.

Parameters

fmt

The formatter resource.

zone

The time zone ID string of the time zone to use. If NULL or the empty string, the default time zone for the runtime is used.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.0.0 This function has been removed.
5.5.0 This function has been deprecated.

Examples

Example #1 datefmt_set_timezone_id() example

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timezone_id of the formatter is : ' datefmt_get_timezone_id($fmt);
datefmt_set_timezone_id($fmt'CN');
echo 
'Now timezone_id of the formatter is : ' datefmt_get_timezone_id($fmt);
?>

Example #2 OO example

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
echo 
'timezone_id of the formatter is : ' $fmt->getTimezoneId();
$fmt->setTimezoneId('CN');
echo 
'Now timezone_id of the formatter is : ' $fmt->getTimezoneId();

?>

The above example will output:

   timezone_id of the formatter is : America/Los_Angeles
   Now timezone_id of the formatter is : CN
   

See Also



IntlDateFormatter::setTimeZone

datefmt_set_timezone

(PHP 5 >= 5.5.0, PHP 7, PECL intl >= 3.0.0)

IntlDateFormatter::setTimeZone -- datefmt_set_timezoneSets formatterʼs timezone

Description

Object oriented style

public IntlDateFormatter::setTimeZone ( mixed $zone ) : bool

Procedural style

datefmt_set_timezone ( IntlDateFormatter $fmt , mixed $zone ) : bool

Sets the timezone used for the IntlDateFormatter. object.

Parameters

fmt

The formatter resource.

zone

The timezone to use for this formatter. This can be specified in the following forms:

Return Values

Returns TRUE on success and FALSE on failure.

Examples

Example #1 IntlDateFormatter::setTimeZone() examples

<?php
ini_set
('date.timezone''Europe/Amsterdam');

$formatter IntlDateFormatter::create(NULLNULLNULL"UTC");

$formatter->setTimeZone(NULL);
echo 
"NULL\n    "$formatter->getTimeZone()->getId(), "\n";

$formatter->setTimeZone(IntlTimeZone::createTimeZone('Europe/Lisbon'));
echo 
"IntlTimeZone\n    "$formatter->getTimeZone()->getId(), "\n";

$formatter->setTimeZone(new DateTimeZone('Europe/Paris'));
echo 
"DateTimeZone\n    "$formatter->getTimeZone()->getId(), "\n";

$formatter->setTimeZone('Europe/Rome');
echo 
"String\n    "$formatter->getTimeZone()->getId(), "\n";

$formatter->setTimeZone('GMT+00:30');
print_r($formatter->getTimeZone());

The above example will output:

   NULL
       Europe/Amsterdam
   IntlTimeZone
       Europe/Lisbon
   DateTimeZone
       Europe/Paris
   String
       Europe/Rome
   IntlTimeZone Object
   (
       [valid] => 1
       [id] => GMT+00:30
       [rawOffset] => 1800000
       [currentOffset] => 1800000
   )
   
   

See Also


Table of Contents



The ResourceBundle class

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

Introduction

Localized software products often require sets of data that are to be customized depending on current locale, e.g.: messages, labels, formatting patterns. ICU resource mechanism allows to define sets of resources that the application can load on locale basis, while accessing them in unified locale-independent fashion.

This class implements access to ICU resource data files. These files are binary data arrays which ICU uses to store the localized data.

ICU resource bundle can hold simple resources and complex resources. Complex resources are containers which can be either integer-indexed or string-indexed (just like PHP arrays). Simple resources can be of the following types: string, integer, binary data field or integer array.

ResourceBundle supports direct access to the data through array access pattern and iteration via foreach, as well as access via class methods. The result will be PHP value for simple resources and ResourceBundle object for complex ones. All resources are read-only.

Class synopsis

ResourceBundle {
/* Methods */
public __construct ( string $locale , string $bundlename [, bool $fallback ] )
public count ( void ) : int
public static create ( string $locale , string $bundlename [, bool $fallback ] ) : ResourceBundle
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public get ( string|int $index [, bool $fallback = TRUE ] ) : mixed
public getLocales ( string $bundlename ) : array
}

ResourceBundle::count

resourcebundle_count

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::count -- resourcebundle_countGet number of elements in the bundle

Description

Object oriented style

public ResourceBundle::count ( void ) : int

Procedural style

resourcebundle_count ( ResourceBundle $r ) : int

Get the number of elements in the bundle.

Parameters

r

ResourceBundle object.

Return Values

Returns number of elements in the bundle.

Examples

Example #1 resourcebundle_count() example

<?php
$r 
resourcebundle_create'es'"/usr/share/data/myapp");
echo 
resourcebundle_count($r);
?>

Example #2 OO example

<?php
$r 
= new ResourceBundle'es'"/usr/share/data/myapp");
echo 
$r->count();
?>

The above example will output:

   42
   

See Also



ResourceBundle::create

resourcebundle_create

ResourceBundle::__construct

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::create -- resourcebundle_create -- ResourceBundle::__constructCreate a resource bundle

Description

Object oriented style (method)

public static ResourceBundle::create ( string $locale , string $bundlename [, bool $fallback ] ) : ResourceBundle

Procedural style

resourcebundle_create ( string $locale , string $bundlename [, bool $fallback ] ) : ResourceBundle

Object oriented style (constructor):

public ResourceBundle::__construct ( string $locale , string $bundlename [, bool $fallback ] )

Creates a resource bundle.

Parameters

locale

Locale for which the resources should be loaded (locale name, e.g. en_CA).

bundlename

The directory where the data is stored or the name of the .dat file.

fallback

Whether locale should match exactly or fallback to parent locale is allowed.

Return Values

Returns ResourceBundle object or NULL on error.

Examples

Example #1 resourcebundle_create() example

<?php
$r 
resourcebundle_create'es'"/usr/share/data/myapp");
echo 
$r['teststring'];
?>

Example #2 ResourceBundle::create() example

<?php
$r 
ResourceBundle::create'es'"/usr/share/data/myapp");
echo 
$r['teststring'];
?>

The above example will output:

   ¡Hola, mundo!
   

See Also



ResourceBundle::getErrorCode

resourcebundle_get_error_code

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::getErrorCode -- resourcebundle_get_error_codeGet bundle's last error code

Description

Object oriented style

public ResourceBundle::getErrorCode ( void ) : int

Procedural style

resourcebundle_get_error_code ( ResourceBundle $r ) : int

Get error code from the last function performed by the bundle object.

Parameters

r

ResourceBundle object.

Return Values

Returns error code from last bundle object call.

Examples

Example #1 resourcebundle_get_error_code() example

<?php
$r 
resourcebundle_create'es'"/usr/share/data/myapp");
echo 
$r['somestring'];
if(
intl_is_failure(resourcebundle_get_error_code($r))) {
    
report_error("Bundle error");
}
?>

Example #2 OO example

<?php
$r 
= new ResourceBundle'es'"/usr/share/data/myapp");
echo 
$r['somestring'];
if(
intl_is_failure(ResourceBundle::getErrorCode($r))) {
    
report_error("Bundle error");
}
?>

See Also



ResourceBundle::getErrorMessage

resourcebundle_get_error_message

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::getErrorMessage -- resourcebundle_get_error_messageGet bundle's last error message

Description

Object oriented style

public ResourceBundle::getErrorMessage ( void ) : string

Procedural style

resourcebundle_get_error_message ( ResourceBundle $r ) : string

Get error message from the last function performed by the bundle object.

Parameters

r

ResourceBundle object.

Return Values

Returns error message from last bundle object's call.

Examples

Example #1 resourcebundle_get_error_message() example

<?php
$r 
resourcebundle_create'es'"/usr/share/data/myapp");
echo 
$r['somestring'];
if(
intl_is_failure(resourcebundle_get_error_code($r))) {
    
report_error("Bundle error: ".resourcebundle_get_error_message($r));
}
?>

Example #2 OO example

<?php
$r 
= new ResourceBundle'es'"/usr/share/data/myapp");
echo 
$r['somestring'];
if(
intl_is_failure(ResourceBundle::getErrorCode($r))) {
    
report_error("Bundle error: ".ResourceBundle::getErrorMessage($r));
}
?>

See Also



ResourceBundle::get

resourcebundle_get

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::get -- resourcebundle_getGet data from the bundle

Description

Object oriented style

public ResourceBundle::get ( string|int $index [, bool $fallback = TRUE ] ) : mixed

Procedural style

resourcebundle_get ( ResourceBundle $r , string|int $index [, bool $fallback = TRUE ] ) : mixed

Get the data from the bundle by index or string key.

Parameters

r

ResourceBundle object.

index

Data index, must be string or integer.

fallback

Whether locale should match exactly or fallback to parent locale is allowed.

Return Values

Returns the data located at the index or NULL on error. Strings, integers and binary data strings are returned as corresponding PHP types, integer array is returned as PHP array. Complex types are returned as ResourceBundle object.

Examples

Example #1 resourcebundle_get() example

<?php
$r 
resourcebundle_create'es'"/usr/share/data/myapp");
echo 
resourcebundle_get($r'somestring');
?>

Example #2 OO example

<?php
$r 
= new ResourceBundle'es'"/usr/share/data/myapp");
echo 
$r->get('somestring');
?>

The above example will output:

   ?Hola, mundo!
   

See Also



ResourceBundle::getLocales

resourcebundle_locales

(PHP 5 >= 5.3.2, PHP 7, PECL intl >= 2.0.0)

ResourceBundle::getLocales -- resourcebundle_localesGet supported locales

Description

Object oriented style

public ResourceBundle::getLocales ( string $bundlename ) : array

Procedural style

resourcebundle_locales ( string $bundlename ) : array

Get available locales from ResourceBundle name.

Parameters

bundlename

Path of ResourceBundle for which to get available locales, or empty string for default locales list.

Return Values

Returns the list of locales supported by the bundle.

Examples

Example #1 resourcebundle_locales() example

<?php
$bundle 
"/user/share/data/myapp";
echo 
join(PHP_EOLresourcebundle_locales($bundle));
?>

The above example will output something similar to:

   es
   root
   

Example #2 OO example

<?php
$bundle 
"/usr/share/data/myapp";
$r = new ResourceBundle'es'$bundle);
echo 
join("\n"$r->getLocales($bundle));
?>

The above example will output something similar to:

   es
   root
   

See Also


Table of Contents



The Spoofchecker class

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Introduction

This class is provided because Unicode contains large number of characters and incorporates the varied writing systems of the world and their incorrect usage can expose programs or systems to possible security attacks using characters similarity.

Provided methods allow to check whether an individual string is likely an attempt at confusing the reader (spoof detection), such as "pаypаl" spelled with Cyrillic 'а' characters.

Class synopsis

Spoofchecker {
/* Constants */
const number ASCII = 0x10000000 ;
const number HIGHLY_RESTRICTIVE = 0x30000000 ;
const number MODERATELY_RESTRICTIVE = 0x40000000 ;
const number MINIMALLY_RESTRICTIVE = 0x50000000 ;
const number UNRESTRICTIVE = 0x60000000 ;
const number SINGLE_SCRIPT_RESTRICTIVE = 0x20000000 ;
const integer SINGLE_SCRIPT_CONFUSABLE = 1 ;
const integer MIXED_SCRIPT_CONFUSABLE = 2 ;
const integer WHOLE_SCRIPT_CONFUSABLE = 4 ;
const integer ANY_CASE = 8 ;
const integer SINGLE_SCRIPT = 16 ;
const integer INVISIBLE = 32 ;
const integer CHAR_LIMIT = 64 ;
/* Methods */
public areConfusable ( string $str1 , string $str2 [, string &$error ] ) : bool
public __construct ( void )
public isSuspicious ( string $text [, string &$error ] ) : bool
public setAllowedLocales ( string $locale_list ) : void
public setChecks ( int $checks ) : void
}

Predefined Constants

Spoofchecker::ASCII

Spoofchecker::HIGHLY_RESTRICTIVE

Spoofchecker::MODERATELY_RESTRICTIVE

Spoofchecker::MINIMALLY_RESTRICTIVE

Spoofchecker::UNRESTRICTIVE

Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE

Spoofchecker::SINGLE_SCRIPT_CONFUSABLE

Spoofchecker::MIXED_SCRIPT_CONFUSABLE

Spoofchecker::WHOLE_SCRIPT_CONFUSABLE

Spoofchecker::ANY_CASE

Spoofchecker::SINGLE_SCRIPT

Spoofchecker::INVISIBLE

Spoofchecker::CHAR_LIMIT

Changelog

Version Description
7.3.0 Class constants used by Spoofchecker::setRestrictionLevel() such as Spoofchecker::ASCII, Spoofchecker::HIGHLY_RESTRICTIVE, Spoofchecker::MODERATELY_RESTRICTIVE, Spoofchecker::MINIMALLY_RESTRICTIVE, Spoofchecker::UNRESTRICTIVE, Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE has been added.

Spoofchecker::areConfusable

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Spoofchecker::areConfusableChecks if given strings can be confused

Description

public Spoofchecker::areConfusable ( string $str1 , string $str2 [, string &$error ] ) : bool

Checks whether two given strings can easily be mistaken.

Parameters

str1

First string to check.

str2

Second string to check.

error

This variable is set by-reference to string containing an error, if there were any.

Return Values

Returns TRUE if two given strings can be confused, FALSE otherwise.

Examples

Example #1 Spoofchecker::areConfusable() example

<?php
$checker 
= new Spoofchecker();

$checker->areConfusable('google.com''goog1e.com'); // true
// Lower l can be confused with digit one

$checker->areConfusable('google.com''g00g1e.com'); // false
// Zero (0) cannot be easily confused with "o" letter



Spoofchecker::__construct

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Spoofchecker::__constructConstructor

Description

public Spoofchecker::__construct ( void )

Creates new instance of Spoofchecker.

Parameters

This function has no parameters.

Return Values

Returns Spoofchecker instance.



Spoofchecker::isSuspicious

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Spoofchecker::isSuspiciousChecks if a given text contains any suspicious characters

Description

public Spoofchecker::isSuspicious ( string $text [, string &$error ] ) : bool

Checks if given string contains any suspicious characters like letters which are almost identical visually, but are Unicode characters from different sets.

Parameters

text

String to test.

error

This variable is set by-reference to string containing an error, if there were any.

Return Values

Returns TRUE if there are suspicious characters, FALSE otherwise.

Examples

Example #1 Spoofchecker::isSuspicious() example

<?php
$checker 
= new Spoofchecker();

$checker->isSuspicious('google.com'); // FALSE: only ASCII characters

$checker->isSuspicious('Рaypal.com'); // TRUE
// The first letter is from Cyrylic, not a regular latin "P"



Spoofchecker::setAllowedLocales

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Spoofchecker::setAllowedLocalesLocales to use when running checks

Description

public Spoofchecker::setAllowedLocales ( string $locale_list ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale_list

Return Values



Spoofchecker::setChecks

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Spoofchecker::setChecksSet the checks to run

Description

public Spoofchecker::setChecks ( int $checks ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

checks

Return Values


Table of Contents



The Transliterator class

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Introduction

Transliterator provides transliteration of strings.

Class synopsis

Transliterator {
/* Constants */
const integer FORWARD = 0 ;
const integer REVERSE = 1 ;
/* Properties */
public id ;
/* Methods */
private __construct ( void )
public static create ( string $id [, int $direction ] ) : Transliterator
public static createFromRules ( string $rules [, string $direction ] ) : Transliterator
public createInverse ( void ) : Transliterator
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public static listIDs ( void ) : array
public transliterate ( string $subject [, int $start [, int $end ]] ) : string
}

Properties

id

Predefined Constants

Transliterator::FORWARD

Transliterator::REVERSE


Transliterator::__construct

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::__constructPrivate constructor to deny instantiation

Description

private Transliterator::__construct ( void )

This method should not be called. Its only purpose is to deny instantiation with the new operator.

Use the factory methods Transliterator::create() or Transliterator::createFromRules() instead.

Parameters

This function has no parameters.

Return Values

This method should not be executed. If it is (e.g. through reflection), then its return value is unspecified.

See Also



Transliterator::create

transliterator_create

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::create -- transliterator_createCreate a transliterator

Description

Object oriented style

public static Transliterator::create ( string $id [, int $direction ] ) : Transliterator

Procedural style

transliterator_create ( string $id [, int $direction ] ) : Transliterator

Opens a Transliterator by ID.

Warning

This function is currently not documented; only its argument list is available.

Parameters

id

The ID. A list of all registered transliterator IDs can be retrieved by using Transliterator::listIDs().

direction

The direction, defaults to Transliterator::FORWARD. May also be set to Transliterator::REVERSE.

Return Values

Returns a Transliterator object on success, or NULL on failure.

See Also



Transliterator::createFromRules

transliterator_create_from_rules

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::createFromRules -- transliterator_create_from_rulesCreate transliterator from rules

Description

Object oriented style

public static Transliterator::createFromRules ( string $rules [, string $direction ] ) : Transliterator

Procedural style

transliterator_create_from_rules ( string $id [, int $direction ] ) : Transliterator

Creates a Transliterator from rules.

Warning

This function is currently not documented; only its argument list is available.

Parameters

rules

The rules as defined in Transform Rules Syntax of UTS #35: Unicode LDML.

direction

The direction, defaults to >Transliterator::FORWARD. May also be set to Transliterator::REVERSE.

Return Values

Returns a Transliterator object on success, or NULL on failure.

See Also



Transliterator::createInverse

transliterator_create_inverse

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::createInverse -- transliterator_create_inverseCreate an inverse transliterator

Description

Object oriented style

public Transliterator::createInverse ( void ) : Transliterator

Procedural style

transliterator_create_inverse ( void ) : Transliterator

Opens the inverse transliterator.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Returns a Transliterator object on success, or NULL on failure

See Also



Transliterator::getErrorCode

transliterator_get_error_code

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::getErrorCode -- transliterator_get_error_codeGet last error code

Description

Object oriented style

public Transliterator::getErrorCode ( void ) : int

Procedural style

transliterator_get_error_code ( Transliterator $trans ) : int

Gets the last error code for this transliterator.

Warning

This function is currently not documented; only its argument list is available.

Parameters

trans

Return Values

The error code on success, or FALSE if none exists, or on failure.

See Also



Transliterator::getErrorMessage

transliterator_get_error_message

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::getErrorMessage -- transliterator_get_error_messageGet last error message

Description

Object oriented style

public Transliterator::getErrorMessage ( void ) : string

Procedural style

transliterator_get_error_message ( Transliterator $trans ) : string

Gets the last error message for this transliterator.

Warning

This function is currently not documented; only its argument list is available.

Parameters

trans

Return Values

The error message on success, or FALSE if none exists, or on failure.

See Also



Transliterator::listIDs

transliterator_list_ids

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::listIDs -- transliterator_list_idsGet transliterator IDs

Description

Object oriented style

public static Transliterator::listIDs ( void ) : array

Procedural style

transliterator_list_ids ( void ) : array

Returns an array with the registered transliterator IDs.

Parameters

This function has no parameters.

Return Values

An array of registered transliterator IDs on success, or FALSE on failure.

Examples

Example #1 Retrieving the registered transliterator IDs

<?php
print_r
(Transliterator::listIDs());
?>

The above example will output something similar to:

   Array
   (
       [0] => ASCII-Latin
       [1] => Accents-Any
       [2] => Amharic-Latin/BGN
       [3] => Any-Accents
       [4] => Any-Publishing
   ...
       [650] => Any-ps_Latn/BGN
       [651] => Any-tk/BGN
       [652] => Any-ch_FONIPA
       [653] => Any-cs_FONIPA
       [654] => Any-cy_FONIPA
   )
   

See Also



Transliterator::transliterate

transliterator_transliterate

(PHP 5 >= 5.4.0, PHP 7, PECL intl >= 2.0.0)

Transliterator::transliterate -- transliterator_transliterateTransliterate a string

Description

Object oriented style

public Transliterator::transliterate ( string $subject [, int $start [, int $end ]] ) : string

Procedural style

transliterator_transliterate ( mixed $transliterator , string $subject [, int $start [, int $end ]] )

Transforms a string or part thereof using an ICU transliterator.

Parameters

transliterator

In the procedural version, either a Transliterator or a string from which a Transliterator can be built.

subject

The string to be transformed.

start

The start index (in UTF-16 code units) from which the string will start to be transformed, inclusive. Indexing starts at 0. The text before will be left as is.

end

The end index (in UTF-16 code units) until which the string will be transformed, exclusive. Indexing starts at 0. The text after will be left as is.

Return Values

The transformed string on success, or FALSE on failure.

Examples

Example #1 Converting escaped UTF-16 code units

<?php
$s 
"\u304A\u65E9\u3046\u3054\u3056\u3044\u307E\u3059";
echo 
transliterator_transliterate("Hex-Any/Java"$s), "\n";

//now the reverse operation with a supplementary character
$supplChar html_entity_decode('&#x1D11E;');
echo 
mb_strlen($supplChar"UTF-8"), "\n";
$encSupplChar transliterator_transliterate("Any-Hex/Java"$supplChar);
//echoes two encoded UTF-16 code units
echo $encSupplChar"\n";
//and back
echo transliterator_transliterate("Hex-Any/Java"$encSupplChar), "\n";
?>

The above example will output something similar to:

   お早うございます
   1
   \uD834\uDD1E
   𝄞
   
   

See Also


Table of Contents



The IntlBreakIterator class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

A “break iterator” is an ICU object that exposes methods for locating boundaries in text (e.g. word or sentence boundaries). The PHP IntlBreakIterator serves as the base class for all types of ICU break iterators. Where extra functionality is available, the intl extension may expose the ICU break iterator with suitable subclasses, such as IntlRuleBasedBreakIterator or IntlCodePointBreakIterator.

This class implements Traversable. Traversing an IntlBreakIterator yields non-negative integer values representing the successive locations of the text boundaries, expressed as UTF-8 code units (byte) counts, taken from the beginning of the text (which has the location 0). The keys yielded by the iterator simply form the sequence of natural numbers {0, 1, 2, …}.

Class synopsis

IntlBreakIterator implements Traversable {
/* Constants */
const integer DONE = -1 ;
const integer WORD_NONE = 0 ;
const integer WORD_NONE_LIMIT = 100 ;
const integer WORD_NUMBER = 100 ;
const integer WORD_NUMBER_LIMIT = 200 ;
const integer WORD_LETTER = 200 ;
const integer WORD_LETTER_LIMIT = 300 ;
const integer WORD_KANA = 300 ;
const integer WORD_KANA_LIMIT = 400 ;
const integer WORD_IDEO = 400 ;
const integer WORD_IDEO_LIMIT = 500 ;
const integer LINE_SOFT = 0 ;
const integer LINE_SOFT_LIMIT = 100 ;
const integer LINE_HARD = 100 ;
const integer LINE_HARD_LIMIT = 200 ;
const integer SENTENCE_TERM = 0 ;
const integer SENTENCE_TERM_LIMIT = 100 ;
const integer SENTENCE_SEP = 100 ;
const integer SENTENCE_SEP_LIMIT = 200 ;
/* Methods */
private __construct ( void )
public static createCharacterInstance ([ string $locale ] ) : IntlBreakIterator
public static createCodePointInstance ( void ) : IntlBreakIterator
public static createLineInstance ([ string $locale ] ) : IntlBreakIterator
public static createSentenceInstance ([ string $locale ] ) : IntlBreakIterator
public static createTitleInstance ([ string $locale ] ) : IntlBreakIterator
public static createWordInstance ([ string $locale ] ) : IntlBreakIterator
public current ( void ) : int
public first ( void ) : int
public following ( int $offset ) : int
public getErrorCode ( void ) : int
intl_get_error_code ( void ) : int
public getErrorMessage ( void ) : string
intl_get_error_message ( void ) : string
public getLocale ( string $locale_type ) : string
public getPartsIterator ([ int $key_type = IntlPartsIterator::KEY_SEQUENTIAL ] ) : IntlPartsIterator
public getText ( void ) : string
public isBoundary ( int $offset ) : bool
public last ( void ) : int
public next ([ int $offset ] ) : int
public preceding ( int $offset ) : int
public previous ( void ) : int
public setText ( string $text ) : bool
}

Predefined Constants

IntlBreakIterator::DONE

IntlBreakIterator::WORD_NONE

IntlBreakIterator::WORD_NONE_LIMIT

IntlBreakIterator::WORD_NUMBER

IntlBreakIterator::WORD_NUMBER_LIMIT

IntlBreakIterator::WORD_LETTER

IntlBreakIterator::WORD_LETTER_LIMIT

IntlBreakIterator::WORD_KANA

IntlBreakIterator::WORD_KANA_LIMIT

IntlBreakIterator::WORD_IDEO

IntlBreakIterator::WORD_IDEO_LIMIT

IntlBreakIterator::LINE_SOFT

IntlBreakIterator::LINE_SOFT_LIMIT

IntlBreakIterator::LINE_HARD

IntlBreakIterator::LINE_HARD_LIMIT

IntlBreakIterator::SENTENCE_TERM

IntlBreakIterator::SENTENCE_TERM_LIMIT

IntlBreakIterator::SENTENCE_SEP

IntlBreakIterator::SENTENCE_SEP_LIMIT


IntlBreakIterator::__construct

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::__constructPrivate constructor for disallowing instantiation

Description

private IntlBreakIterator::__construct ( void )

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::createCharacterInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createCharacterInstance Create break iterator for boundaries of combining character sequences

Description

public static IntlBreakIterator::createCharacterInstance ([ string $locale ] ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



IntlBreakIterator::createCodePointInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createCodePointInstanceCreate break iterator for boundaries of code points

Description

public static IntlBreakIterator::createCodePointInstance ( void ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::createLineInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createLineInstance Create break iterator for logically possible line breaks

Description

public static IntlBreakIterator::createLineInstance ([ string $locale ] ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



IntlBreakIterator::createSentenceInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createSentenceInstanceCreate break iterator for sentence breaks

Description

public static IntlBreakIterator::createSentenceInstance ([ string $locale ] ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



IntlBreakIterator::createTitleInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createTitleInstanceCreate break iterator for title-casing breaks

Description

public static IntlBreakIterator::createTitleInstance ([ string $locale ] ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



IntlBreakIterator::createWordInstance

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::createWordInstanceCreate break iterator for word breaks

Description

public static IntlBreakIterator::createWordInstance ([ string $locale ] ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale

Return Values



IntlBreakIterator::current

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::currentGet index of current position

Description

public IntlBreakIterator::current ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::first

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::firstSet position to the first character in the text

Description

public IntlBreakIterator::first ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::following

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::following Advance the iterator to the first boundary following specified offset

Description

public IntlBreakIterator::following ( int $offset ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Return Values



IntlBreakIterator::getErrorCode

intl_get_error_code

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::getErrorCode -- intl_get_error_codeGet last error code on the object

Description

Object oriented style (method):

public IntlBreakIterator::getErrorCode ( void ) : int

Procedural style:

intl_get_error_code ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::getErrorMessage

intl_get_error_message

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::getErrorMessage -- intl_get_error_messageGet last error message on the object

Description

Object oriented style (method):

public IntlBreakIterator::getErrorMessage ( void ) : string

Procedural style:

intl_get_error_message ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::getLocale

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::getLocaleGet the locale associated with the object

Description

public IntlBreakIterator::getLocale ( string $locale_type ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

locale_type

Return Values



IntlBreakIterator::getPartsIterator

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::getPartsIteratorCreate iterator for navigating fragments between boundaries

Description

public IntlBreakIterator::getPartsIterator ([ int $key_type = IntlPartsIterator::KEY_SEQUENTIAL ] ) : IntlPartsIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

key_type

Optional key type. Possible values are:

  • IntlPartsIterator::KEY_SEQUENTIAL - The default. Sequentially increasing integers used as key.
  • IntlPartsIterator::KEY_LEFT - Byte offset left of current part used as key.
  • IntlPartsIterator::KEY_RIGHT - Byte offset right of current part used as key.

Return Values



IntlBreakIterator::getText

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::getTextGet the text being scanned

Description

public IntlBreakIterator::getText ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::isBoundary

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::isBoundaryTell whether an offset is a boundaryʼs offset

Description

public IntlBreakIterator::isBoundary ( int $offset ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Return Values



IntlBreakIterator::last

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::lastSet the iterator position to index beyond the last character

Description

public IntlBreakIterator::last ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::next

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::nextAdvance the iterator the next boundary

Description

public IntlBreakIterator::next ([ int $offset ] ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Return Values



IntlBreakIterator::preceding

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::precedingSet the iterator position to the first boundary before an offset

Description

public IntlBreakIterator::preceding ( int $offset ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Return Values



IntlBreakIterator::previous

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::previousSet the iterator position to the boundary immediately before the current

Description

public IntlBreakIterator::previous ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlBreakIterator::setText

(PHP 5 >= 5.5.0, PHP 7)

IntlBreakIterator::setTextSet the text being scanned

Description

public IntlBreakIterator::setText ( string $text ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

text

Return Values


Table of Contents



The IntlRuleBasedBreakIterator class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

A subclass of IntlBreakIterator that encapsulates ICU break iterators whose behavior is specified using a set of rules. This is the most common kind of break iterators.

These rules are described in the » ICU Boundary Analysis User Guide.

Class synopsis

IntlRuleBasedBreakIterator extends IntlBreakIterator implements Traversable {
/* Inherited constants */
const integer IntlBreakIterator::DONE = -1 ;
const integer IntlBreakIterator::WORD_NONE = 0 ;
const integer IntlBreakIterator::WORD_NONE_LIMIT = 100 ;
const integer IntlBreakIterator::WORD_NUMBER = 100 ;
const integer IntlBreakIterator::WORD_NUMBER_LIMIT = 200 ;
const integer IntlBreakIterator::WORD_LETTER = 200 ;
const integer IntlBreakIterator::WORD_LETTER_LIMIT = 300 ;
const integer IntlBreakIterator::WORD_KANA = 300 ;
const integer IntlBreakIterator::WORD_KANA_LIMIT = 400 ;
const integer IntlBreakIterator::WORD_IDEO = 400 ;
const integer IntlBreakIterator::WORD_IDEO_LIMIT = 500 ;
const integer IntlBreakIterator::LINE_SOFT = 0 ;
const integer IntlBreakIterator::LINE_SOFT_LIMIT = 100 ;
const integer IntlBreakIterator::LINE_HARD = 100 ;
const integer IntlBreakIterator::LINE_HARD_LIMIT = 200 ;
const integer IntlBreakIterator::SENTENCE_TERM = 0 ;
const integer IntlBreakIterator::SENTENCE_TERM_LIMIT = 100 ;
const integer IntlBreakIterator::SENTENCE_SEP = 100 ;
const integer IntlBreakIterator::SENTENCE_SEP_LIMIT = 200 ;
/* Methods */
public __construct ( string $rules [, string $areCompiled ] )
public getBinaryRules ( void ) : string
public getRules ( void ) : string
public getRuleStatus ( void ) : int
public getRuleStatusVec ( void ) : array
/* Inherited methods */
public static IntlBreakIterator::createCharacterInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createLineInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createSentenceInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createTitleInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createWordInstance ([ string $locale ] ) : IntlBreakIterator
public IntlBreakIterator::current ( void ) : int
public IntlBreakIterator::first ( void ) : int
public IntlBreakIterator::following ( int $offset ) : int
public IntlBreakIterator::getErrorCode ( void ) : int
intl_get_error_code ( void ) : int
public IntlBreakIterator::getErrorMessage ( void ) : string
intl_get_error_message ( void ) : string
public IntlBreakIterator::getLocale ( string $locale_type ) : string
public IntlBreakIterator::getPartsIterator ([ int $key_type = IntlPartsIterator::KEY_SEQUENTIAL ] ) : IntlPartsIterator
public IntlBreakIterator::getText ( void ) : string
public IntlBreakIterator::isBoundary ( int $offset ) : bool
public IntlBreakIterator::last ( void ) : int
public IntlBreakIterator::next ([ int $offset ] ) : int
public IntlBreakIterator::preceding ( int $offset ) : int
public IntlBreakIterator::previous ( void ) : int
public IntlBreakIterator::setText ( string $text ) : bool
}

IntlRuleBasedBreakIterator::__construct

(PHP 5 >= 5.5.0, PHP 7)

IntlRuleBasedBreakIterator::__constructCreate iterator from ruleset

Description

public IntlRuleBasedBreakIterator::__construct ( string $rules [, string $areCompiled ] )

Warning

This function is currently not documented; only its argument list is available.

Parameters

rules

areCompiled

Return Values



IntlRuleBasedBreakIterator::getBinaryRules

(PHP 5 >= 5.5.0, PHP 7)

IntlRuleBasedBreakIterator::getBinaryRulesGet the binary form of compiled rules

Description

public IntlRuleBasedBreakIterator::getBinaryRules ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlRuleBasedBreakIterator::getRules

(PHP 5 >= 5.5.0, PHP 7)

IntlRuleBasedBreakIterator::getRulesGet the rule set used to create this object

Description

public IntlRuleBasedBreakIterator::getRules ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlRuleBasedBreakIterator::getRuleStatus

(PHP 5 >= 5.5.0, PHP 7)

IntlRuleBasedBreakIterator::getRuleStatusGet the largest status value from the break rules that determined the current break position

Description

public IntlRuleBasedBreakIterator::getRuleStatus ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlRuleBasedBreakIterator::getRuleStatusVec

(PHP 5 >= 5.5.0, PHP 7)

IntlRuleBasedBreakIterator::getRuleStatusVecGet the status values from the break rules that determined the current break position

Description

public IntlRuleBasedBreakIterator::getRuleStatusVec ( void ) : array

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values


Table of Contents



The IntlCodePointBreakIterator class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

This break iterator identifies the boundaries between UTF-8 code points.

Class synopsis

IntlCodePointBreakIterator extends IntlBreakIterator implements Traversable {
/* Inherited constants */
const integer IntlBreakIterator::DONE = -1 ;
const integer IntlBreakIterator::WORD_NONE = 0 ;
const integer IntlBreakIterator::WORD_NONE_LIMIT = 100 ;
const integer IntlBreakIterator::WORD_NUMBER = 100 ;
const integer IntlBreakIterator::WORD_NUMBER_LIMIT = 200 ;
const integer IntlBreakIterator::WORD_LETTER = 200 ;
const integer IntlBreakIterator::WORD_LETTER_LIMIT = 300 ;
const integer IntlBreakIterator::WORD_KANA = 300 ;
const integer IntlBreakIterator::WORD_KANA_LIMIT = 400 ;
const integer IntlBreakIterator::WORD_IDEO = 400 ;
const integer IntlBreakIterator::WORD_IDEO_LIMIT = 500 ;
const integer IntlBreakIterator::LINE_SOFT = 0 ;
const integer IntlBreakIterator::LINE_SOFT_LIMIT = 100 ;
const integer IntlBreakIterator::LINE_HARD = 100 ;
const integer IntlBreakIterator::LINE_HARD_LIMIT = 200 ;
const integer IntlBreakIterator::SENTENCE_TERM = 0 ;
const integer IntlBreakIterator::SENTENCE_TERM_LIMIT = 100 ;
const integer IntlBreakIterator::SENTENCE_SEP = 100 ;
const integer IntlBreakIterator::SENTENCE_SEP_LIMIT = 200 ;
/* Methods */
public getLastCodePoint ( void ) : int
/* Inherited methods */
public static IntlBreakIterator::createCharacterInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createLineInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createSentenceInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createTitleInstance ([ string $locale ] ) : IntlBreakIterator
public static IntlBreakIterator::createWordInstance ([ string $locale ] ) : IntlBreakIterator
public IntlBreakIterator::current ( void ) : int
public IntlBreakIterator::first ( void ) : int
public IntlBreakIterator::following ( int $offset ) : int
public IntlBreakIterator::getErrorCode ( void ) : int
intl_get_error_code ( void ) : int
public IntlBreakIterator::getErrorMessage ( void ) : string
intl_get_error_message ( void ) : string
public IntlBreakIterator::getLocale ( string $locale_type ) : string
public IntlBreakIterator::getPartsIterator ([ int $key_type = IntlPartsIterator::KEY_SEQUENTIAL ] ) : IntlPartsIterator
public IntlBreakIterator::getText ( void ) : string
public IntlBreakIterator::isBoundary ( int $offset ) : bool
public IntlBreakIterator::last ( void ) : int
public IntlBreakIterator::next ([ int $offset ] ) : int
public IntlBreakIterator::preceding ( int $offset ) : int
public IntlBreakIterator::previous ( void ) : int
public IntlBreakIterator::setText ( string $text ) : bool
}

IntlCodePointBreakIterator::getLastCodePoint

(PHP 5 >= 5.5.0, PHP 7)

IntlCodePointBreakIterator::getLastCodePointGet last code point passed over after advancing or receding the iterator

Description

public IntlCodePointBreakIterator::getLastCodePoint ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values


Table of Contents



The IntlPartsIterator class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

Objects of this class can be obtained from IntlBreakIterator objects. While the break iterators provide a sequence of boundary positions when iterated, IntlPartsIterator objects provide, as a convenience, the text fragments comprehended between two successive boundaries.

The keys may represent the offset of the left boundary, right boundary, or they may just the sequence of non-negative integers. See IntlBreakIterator::getPartsIterator().

Class synopsis

IntlPartsIterator extends IntlIterator implements Iterator {
/* Constants */
const integer KEY_SEQUENTIAL = 0 ;
const integer KEY_LEFT = 1 ;
const integer KEY_RIGHT = 2 ;
/* Methods */
/* Inherited methods */
public IntlIterator::current ( void ) : mixed
public IntlIterator::key ( void ) : string
public IntlIterator::next ( void ) : void
public IntlIterator::rewind ( void ) : void
public IntlIterator::valid ( void ) : bool
}

Predefined Constants

IntlPartsIterator::KEY_SEQUENTIAL

IntlPartsIterator::KEY_LEFT

IntlPartsIterator::KEY_RIGHT


IntlPartsIterator::getBreakIterator

(PHP 5 >= 5.5.0, PHP 7)

IntlPartsIterator::getBreakIteratorGet IntlBreakIterator backing this parts iterator

Description

public IntlPartsIterator::getBreakIterator ( void ) : IntlBreakIterator

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values


Table of Contents



The UConverter class

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

Introduction

Class synopsis

UConverter {
/* Constants */
const integer REASON_UNASSIGNED = 0 ;
const integer REASON_ILLEGAL = 1 ;
const integer REASON_IRREGULAR = 2 ;
const integer REASON_RESET = 3 ;
const integer REASON_CLOSE = 4 ;
const integer REASON_CLONE = 5 ;
const integer UNSUPPORTED_CONVERTER = -1 ;
const integer SBCS = 0 ;
const integer DBCS = 1 ;
const integer MBCS = 2 ;
const integer LATIN_1 = 3 ;
const integer UTF8 = 4 ;
const integer UTF16_BigEndian = 5 ;
const integer UTF16_LittleEndian = 6 ;
const integer UTF32_BigEndian = 7 ;
const integer UTF32_LittleEndian = 8 ;
const integer EBCDIC_STATEFUL = 9 ;
const integer ISO_2022 = 10 ;
const integer LMBCS_1 = 11 ;
const integer LMBCS_2 = 12 ;
const integer LMBCS_3 = 13 ;
const integer LMBCS_4 = 14 ;
const integer LMBCS_5 = 15 ;
const integer LMBCS_6 = 16 ;
const integer LMBCS_8 = 17 ;
const integer LMBCS_11 = 18 ;
const integer LMBCS_16 = 19 ;
const integer LMBCS_17 = 20 ;
const integer LMBCS_18 = 21 ;
const integer LMBCS_19 = 22 ;
const integer LMBCS_LAST = 22 ;
const integer HZ = 23 ;
const integer SCSU = 24 ;
const integer ISCII = 25 ;
const integer US_ASCII = 26 ;
const integer UTF7 = 27 ;
const integer BOCU1 = 28 ;
const integer UTF16 = 29 ;
const integer UTF32 = 30 ;
const integer CESU8 = 31 ;
const integer IMAP_MAILBOX = 32 ;
/* Methods */
public __construct ([ string $destination_encoding [, string $source_encoding ]] )
public convert ( string $str [, bool $reverse ] ) : string
public fromUCallback ( int $reason , string $source , string $codePoint , int &$error ) : mixed
public static getAliases ( string $name ) : array
public static getAvailable ( void ) : array
public getDestinationEncoding ( void ) : string
public getDestinationType ( void ) : int
public getErrorCode ( void ) : int
public getErrorMessage ( void ) : string
public getSourceEncoding ( void ) : string
public getSourceType ( void ) : int
public static getStandards ( void ) : array
public getSubstChars ( void ) : string
public static reasonText ([ int $reason ] ) : string
public setDestinationEncoding ( string $encoding ) : void
public setSourceEncoding ( string $encoding ) : void
public setSubstChars ( string $chars ) : void
public toUCallback ( int $reason , string $source , string $codeUnits , int &$error ) : mixed
public static transcode ( string $str , string $toEncoding , string $fromEncoding [, array $options ] ) : string
}

Predefined Constants

UConverter::REASON_UNASSIGNED

UConverter::REASON_ILLEGAL

UConverter::REASON_IRREGULAR

UConverter::REASON_RESET

UConverter::REASON_CLOSE

UConverter::REASON_CLONE

UConverter::UNSUPPORTED_CONVERTER

UConverter::SBCS

UConverter::DBCS

UConverter::MBCS

UConverter::LATIN_1

UConverter::UTF8

UConverter::UTF16_BigEndian

UConverter::UTF16_LittleEndian

UConverter::UTF32_BigEndian

UConverter::UTF32_LittleEndian

UConverter::EBCDIC_STATEFUL

UConverter::ISO_2022

UConverter::LMBCS_1

UConverter::LMBCS_2

UConverter::LMBCS_3

UConverter::LMBCS_4

UConverter::LMBCS_5

UConverter::LMBCS_6

UConverter::LMBCS_8

UConverter::LMBCS_11

UConverter::LMBCS_16

UConverter::LMBCS_17

UConverter::LMBCS_18

UConverter::LMBCS_19

UConverter::LMBCS_LAST

UConverter::HZ

UConverter::SCSU

UConverter::ISCII

UConverter::US_ASCII

UConverter::UTF7

UConverter::BOCU1

UConverter::UTF16

UConverter::UTF32

UConverter::CESU8

UConverter::IMAP_MAILBOX


UConverter::__construct

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::__constructCreate UConverter object

Description

public UConverter::__construct ([ string $destination_encoding [, string $source_encoding ]] )

Warning

This function is currently not documented; only its argument list is available.

Parameters

destination_encoding

source_encoding

Return Values



UConverter::convert

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::convertConvert string from one charset to another

Description

public UConverter::convert ( string $str [, bool $reverse ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

str

reverse

Return Values



UConverter::fromUCallback

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::fromUCallbackDefault "from" callback function

Description

public UConverter::fromUCallback ( int $reason , string $source , string $codePoint , int &$error ) : mixed

Warning

This function is currently not documented; only its argument list is available.

Parameters

reason

source

codePoint

error

Return Values



UConverter::getAliases

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getAliasesGet the aliases of the given name

Description

public static UConverter::getAliases ( string $name ) : array

Warning

This function is currently not documented; only its argument list is available.

Parameters

name

Return Values



UConverter::getAvailable

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getAvailableGet the available canonical converter names

Description

public static UConverter::getAvailable ( void ) : array

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getDestinationEncoding

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getDestinationEncodingGet the destination encoding

Description

public UConverter::getDestinationEncoding ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getDestinationType

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getDestinationTypeGet the destination converter type

Description

public UConverter::getDestinationType ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getErrorCode

intl_get_error_code

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getErrorCode -- intl_get_error_codeGet last error code on the object

Description

public UConverter::getErrorCode ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getErrorMessage

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getErrorMessageGet last error message on the object

Description

public UConverter::getErrorMessage ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getSourceEncoding

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getSourceEncodingGet the source encoding

Description

public UConverter::getSourceEncoding ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getSourceType

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getSourceTypeGet the source converter type

Description

public UConverter::getSourceType ( void ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getStandards

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getStandardsGet standards associated to converter names

Description

public static UConverter::getStandards ( void ) : array

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::getSubstChars

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::getSubstCharsGet substitution chars

Description

public UConverter::getSubstChars ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



UConverter::reasonText

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::reasonTextGet string representation of the callback reason

Description

public static UConverter::reasonText ([ int $reason ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

reason

Return Values



UConverter::setDestinationEncoding

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::setDestinationEncodingSet the destination encoding

Description

public UConverter::setDestinationEncoding ( string $encoding ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

encoding

Return Values



UConverter::setSourceEncoding

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::setSourceEncodingSet the source encoding

Description

public UConverter::setSourceEncoding ( string $encoding ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

encoding

Return Values



UConverter::setSubstChars

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::setSubstCharsSet the substitution chars

Description

public UConverter::setSubstChars ( string $chars ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

chars

Return Values



UConverter::toUCallback

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::toUCallbackDefault "to" callback function

Description

public UConverter::toUCallback ( int $reason , string $source , string $codeUnits , int &$error ) : mixed

Warning

This function is currently not documented; only its argument list is available.

Parameters

reason

source

codeUnits

error

Return Values



UConverter::transcode

(PHP 5 >= 5.5.0, PHP 7, PECL >= 3.0.0a1)

UConverter::transcodeConvert string from one charset to another

Description

public static UConverter::transcode ( string $str , string $toEncoding , string $fromEncoding [, array $options ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

str

toEncoding

fromEncoding

options

Return Values


Table of Contents



Grapheme Functions


grapheme_extract

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_extractFunction to extract a sequence of default grapheme clusters from a text buffer, which must be encoded in UTF-8

Description

Procedural style

grapheme_extract ( string $haystack , int $size [, int $extract_type [, int $start = 0 [, int &$next ]]] ) : string

Function to extract a sequence of default grapheme clusters from a text buffer, which must be encoded in UTF-8.

Parameters

haystack

String to search.

size

Maximum number items - based on the $extract_type - to return.

extract_type

Defines the type of units referred to by the $size parameter:

  • GRAPHEME_EXTR_COUNT (default) - $size is the number of default grapheme clusters to extract.
  • GRAPHEME_EXTR_MAXBYTES - $size is the maximum number of bytes returned.
  • GRAPHEME_EXTR_MAXCHARS - $size is the maximum number of UTF-8 characters returned.

start

Starting position in $haystack in bytes - if given, it must be zero or a positive value that is less than or equal to the length of $haystack in bytes, or a negative value that counts from the end of $haystack. If $start does not point to the first byte of a UTF-8 character, the start position is moved to the next character boundary.

next

Reference to a value that will be set to the next starting position. When the call returns, this may point to the first byte position past the end of the string.

Return Values

A string starting at offset $start and ending on a default grapheme cluster boundary that conforms to the $size and $extract_type specified.

Changelog

Version Description
7.1.0 Support for negative starts has been added.

Examples

Example #1 grapheme_extract() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print urlencode(grapheme_extract$char_a_ring_nfd $char_o_diaeresis_nfd1GRAPHEME_EXTR_COUNT2));

?>

The above example will output:

   o%CC%88
   


grapheme_stripos

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_striposFind position (in grapheme units) of first occurrence of a case-insensitive string

Description

Procedural style

grapheme_stripos ( string $haystack , string $needle [, int $offset = 0 ] ) : int

Find position (in grapheme units) of first occurrence of a case-insensitive string

Parameters

haystack

The string to look in. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

offset

The optional $offset parameter allows you to specify where in haystack to start searching as an offset in grapheme units (not bytes or characters). If the offset is negative, it is treated relative to the end of the string. The position returned is still relative to the beginning of haystack regardless of the value of $offset.

Return Values

Returns the position as an integer. If needle is not found, grapheme_stripos() will return boolean FALSE.

Changelog

Version Description
7.1.0 Support for negative offsets has been added.

Examples

Example #1 grapheme_stripos() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"
$char_O_diaeresis_nfd "O\xCC\x88"// 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) normalization form "D"

print grapheme_stripos$char_a_ring_nfd $char_a_ring_nfd $char_o_diaeresis_nfd$char_O_diaeresis_nfd);

?>

The above example will output:

   2
   

See Also



grapheme_stristr

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_stristrReturns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack

Description

Procedural style

grapheme_stristr ( string $haystack , string $needle [, bool $before_needle = FALSE ] ) : string

Returns part of haystack string starting from and including the first occurrence of case-insensitive needle to the end of haystack.

Parameters

haystack

The input string. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

before_needle

If TRUE, grapheme_strstr() returns the part of the haystack before the first occurrence of the needle (excluding needle).

Return Values

Returns the portion of $haystack, or FALSE if $needle is not found.

Examples

Example #1 grapheme_stristr() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"
$char_O_diaeresis_nfd "O\xCC\x88"// 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) normalization form "D"

print urlencode(grapheme_stristr$char_a_ring_nfd $char_o_diaeresis_nfd $char_a_ring_nfd$char_O_diaeresis_nfd));

?>

The above example will output:

   o%CC%88a%CC%8A
   

See Also



grapheme_strlen

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_strlenGet string length in grapheme units

Description

Procedural style

grapheme_strlen ( string $input ) : int

Get string length in grapheme units (not bytes or characters)

Parameters

input

The string being measured for length. It must be a valid UTF-8 string.

Return Values

The length of the string on success, and 0 if the string is empty.

Examples

Example #1 grapheme_strlen() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print grapheme_strlen'abc' $char_a_ring_nfd $char_o_diaeresis_nfd $char_a_ring_nfd);

?>

The above example will output:

   6
   

See Also



grapheme_strpos

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_strposFind position (in grapheme units) of first occurrence of a string

Description

Procedural style

grapheme_strpos ( string $haystack , string $needle [, int $offset = 0 ] ) : int

Find position (in grapheme units) of first occurrence of a string

Parameters

haystack

The string to look in. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

offset

The optional $offset parameter allows you to specify where in $haystack to start searching as an offset in grapheme units (not bytes or characters). If the offset is negative, it is treated relative to the end of the string. The position returned is still relative to the beginning of haystack regardless of the value of $offset.

Return Values

Returns the position as an integer. If needle is not found, grapheme_strpos() will return boolean FALSE.

Changelog

Version Description
7.1.0 Support for negative offsets has been added.

Examples

Example #1 grapheme_strpos() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print grapheme_strpos$char_a_ring_nfd $char_a_ring_nfd $char_o_diaeresis_nfd$char_o_diaeresis_nfd);

?>

The above example will output:

   2
   

See Also



grapheme_strripos

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_strriposFind position (in grapheme units) of last occurrence of a case-insensitive string

Description

Procedural style

grapheme_strripos ( string $haystack , string $needle [, int $offset = 0 ] ) : int

Find position (in grapheme units) of last occurrence of a case-insensitive string

Parameters

haystack

The string to look in. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

offset

The optional $offset parameter allows you to specify where in $haystack to start searching as an offset in grapheme units (not bytes or characters). The position returned is still relative to the beginning of haystack regardless of the value of $offset.

Return Values

Returns the position as an integer. If needle is not found, grapheme_strripos() will return boolean FALSE.

Examples

Example #1 grapheme_strripos() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"
$char_O_diaeresis_nfd "O\xCC\x88"// 'LATIN CAPITAL LETTER O WITH DIAERESIS' (U+00D6) normalization form "D"

print grapheme_strripos$char_a_ring_nfd $char_o_diaeresis_nfd $char_o_diaeresis_nfd$char_O_diaeresis_nfd);

?>

The above example will output:

   2
   

See Also



grapheme_strrpos

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_strrposFind position (in grapheme units) of last occurrence of a string

Description

Procedural style

grapheme_strrpos ( string $haystack , string $needle [, int $offset = 0 ] ) : int

Find position (in grapheme units) of last occurrence of a string

Parameters

haystack

The string to look in. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

offset

The optional $offset parameter allows you to specify where in $haystack to start searching as an offset in grapheme units (not bytes or characters). The position returned is still relative to the beginning of haystack regardless of the value of $offset.

Return Values

Returns the position as an integer. If needle is not found, grapheme_strrpos() will return boolean FALSE.

Examples

Example #1 grapheme_strrpos() example

<?php
$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print grapheme_strrpos$char_a_ring_nfd $char_o_diaeresis_nfd $char_o_diaeresis_nfd$char_o_diaeresis_nfd);
?>

The above example will output:

   2
   

See Also



grapheme_strstr

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_strstrReturns part of haystack string from the first occurrence of needle to the end of haystack

Description

Procedural style

grapheme_strstr ( string $haystack , string $needle [, bool $before_needle = FALSE ] ) : string

Returns part of haystack string from the first occurrence of needle to the end of haystack (including the needle).

Parameters

haystack

The input string. Must be valid UTF-8.

needle

The string to look for. Must be valid UTF-8.

before_needle

If TRUE, grapheme_strstr() returns the part of the haystack before the first occurrence of the needle (excluding the needle).

Return Values

Returns the portion of string, or FALSE if needle is not found.

Examples

Example #1 grapheme_strstr() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print urlencode(grapheme_stristr$char_a_ring_nfd $char_o_diaeresis_nfd $char_a_ring_nfd$char_o_diaeresis_nfd));

?>

The above example will output:

   o%CC%88a%CC%8A
   

See Also



grapheme_substr

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

grapheme_substrReturn part of a string

Description

Procedural style

grapheme_substr ( string $string , int $start [, int $length ] ) : string

Return part of a string

Parameters

string

The input string. Must be valid UTF-8.

start

Start position in default grapheme units. If $start is non-negative, the returned string will start at the $start'th position in $string, counting from zero. If $start is negative, the returned string will start at the $start'th grapheme unit from the end of string.

length

Length in grapheme units. If $length is given and is positive, the string returned will contain at most $length grapheme units beginning from $start (depending on the length of string). If $length is given and is negative, then that many grapheme units will be omitted from the end of string (after the start position has been calculated when a start is negative). If $start denotes a position beyond this truncation, FALSE will be returned.

Return Values

Returns the extracted part of $string.

Changelog

Version Description
5.4 If length is given and positive and the argument string is shorter than the specified length, all the rest of the string according to start parameter is returned. Previously, FALSE was returned.

Examples

Example #1 grapheme_substr() example

<?php

$char_a_ring_nfd 
"a\xCC\x8A";  // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"
$char_o_diaeresis_nfd "o\xCC\x88"// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"

print urlencode(grapheme_substr"ao" $char_a_ring_nfd "bc" $char_o_diaeresis_nfd "O"2, -));
?>

The above example will output:

   a%CC%8Abco%CC%88
   

See Also


Table of Contents



IDN Functions


idn_to_ascii

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.2, PECL idn >= 0.1)

idn_to_asciiConvert domain name to IDNA ASCII form

Description

Procedural style

idn_to_ascii ( string $domain [, int $options = IDNA_DEFAULT [, int $variant = INTL_IDNA_VARIANT_UTS46 [, array &$idna_info ]]] ) : string

This function converts a Unicode domain name to an IDNA ASCII-compatible format.

Parameters

domain

The domain to convert, which must be UTF-8 encoded.

options

Conversion options - combination of IDNA_* constants (except IDNA_ERROR_* constants).

variant

Either INTL_IDNA_VARIANT_2003 (deprecated as of PHP 7.2.0) for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 (only available as of ICU 4.6) for UTS #46.

idna_info

This parameter can be used only if INTL_IDNA_VARIANT_UTS46 was used for variant. In that case, it will be filled with an array with the keys 'result', the possibly illegal result of the transformation, 'isTransitionalDifferent', a boolean indicating whether the usage of the transitional mechanisms of UTS #46 either has or would have changed the result and 'errors', which is an int representing a bitset of the error constants IDNA_ERROR_*.

Return Values

The domain name encoded in ASCII-compatible form, or FALSE on failure

Changelog

Version Description
7.4.0 The default value of variant is now INTL_IDNA_VARIANT_UTS46 instead of the deprecated INTL_IDNA_VARIANT_2003.
7.2.0 INTL_IDNA_VARIANT_2003 has been deprecated; use INTL_IDNA_VARIANT_UTS46 instead.
5.4.0/PECL 2.0.0b1 Added the parameters variant and idna_info; UTS #46 support (requires ICU ≥ 4.6).

Examples

Example #1 idn_to_ascii() example

<?php

echo idn_to_ascii('täst.de'); 

?>

The above example will output:

   xn--tst-qla.de
   

See Also



idn_to_utf8

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.2, PECL idn >= 0.1)

idn_to_utf8Convert domain name from IDNA ASCII to Unicode

Description

Procedural style

idn_to_utf8 ( string $domain [, int $options = IDNA_DEFAULT [, int $variant = INTL_IDNA_VARIANT_UTS46 [, array &$idna_info ]]] ) : string

This function converts a Unicode domain name from an IDNA ASCII-compatible format to plain Unicode, encoded in UTF-8.

Parameters

domain

Domain to convert in an IDNA ASCII-compatible format.

options

Conversion options - combination of IDNA_* constants (except IDNA_ERROR_* constants).

variant

Either INTL_IDNA_VARIANT_2003 (deprecated as of PHP 7.2.0) for IDNA 2003 or INTL_IDNA_VARIANT_UTS46 (only available as of ICU 4.6) for UTS #46.

idna_info

This parameter can be used only if INTL_IDNA_VARIANT_UTS46 was used for variant. In that case, it will be filled with an array with the keys 'result', the possibly illegal result of the transformation, 'isTransitionalDifferent', a boolean indicating whether the usage of the transitional mechanisms of UTS #46 either has or would have changed the result and 'errors', which is an int representing a bitset of the error constants IDNA_ERROR_*.

Return Values

The domain name in Unicode, encoded in UTF-8, or FALSE on failure

Changelog

Version Description
7.4.0 The default value of variant is now INTL_IDNA_VARIANT_UTS46 instead of the deprecated INTL_IDNA_VARIANT_2003.
7.2.0 INTL_IDNA_VARIANT_2003 has been deprecated; use INTL_IDNA_VARIANT_UTS46 instead.
5.4.0/PECL 2.0.0b1 Added the parameters variant and idna_info; UTS #46 support (requires ICU ≥ 4.6).

Examples

Example #1 idn_to_utf8() example

<?php

echo idn_to_utf8('xn--tst-qla.de'); 

?>

The above example will output:

   täst.de
   

See Also


Table of Contents



IntlChar

(PHP 7)

Introduction

IntlChar provides access to a number of utility methods that can be used to access information about Unicode characters.

The methods and constants adhere closely to the names and behavior used by the underlying ICU library.

Class synopsis

IntlChar {
/* Constants */
const string UNICODE_VERSION = 6.3 ;
const integer CODEPOINT_MIN = 0 ;
const integer CODEPOINT_MAX = 1114111 ;
const float NO_NUMERIC_VALUE = -123456789 ;
const integer PROPERTY_ALPHABETIC = 0 ;
const integer PROPERTY_BINARY_START = 0 ;
const integer PROPERTY_ASCII_HEX_DIGIT = 1 ;
const integer PROPERTY_BIDI_CONTROL = 2 ;
const integer PROPERTY_BIDI_MIRRORED = 3 ;
const integer PROPERTY_DASH = 4 ;
const integer PROPERTY_DEFAULT_IGNORABLE_CODE_POINT = 5 ;
const integer PROPERTY_DEPRECATED = 6 ;
const integer PROPERTY_DIACRITIC = 7 ;
const integer PROPERTY_EXTENDER = 8 ;
const integer PROPERTY_FULL_COMPOSITION_EXCLUSION = 9 ;
const integer PROPERTY_GRAPHEME_BASE = 10 ;
const integer PROPERTY_GRAPHEME_EXTEND = 11 ;
const integer PROPERTY_GRAPHEME_LINK = 12 ;
const integer PROPERTY_HEX_DIGIT = 13 ;
const integer PROPERTY_HYPHEN = 14 ;
const integer PROPERTY_ID_CONTINUE = 15 ;
const integer PROPERTY_ID_START = 16 ;
const integer PROPERTY_IDEOGRAPHIC = 17 ;
const integer PROPERTY_IDS_BINARY_OPERATOR = 18 ;
const integer PROPERTY_IDS_TRINARY_OPERATOR = 19 ;
const integer PROPERTY_JOIN_CONTROL = 20 ;
const integer PROPERTY_LOGICAL_ORDER_EXCEPTION = 21 ;
const integer PROPERTY_LOWERCASE = 22 ;
const integer PROPERTY_MATH = 23 ;
const integer PROPERTY_NONCHARACTER_CODE_POINT = 24 ;
const integer PROPERTY_QUOTATION_MARK = 25 ;
const integer PROPERTY_RADICAL = 26 ;
const integer PROPERTY_SOFT_DOTTED = 27 ;
const integer PROPERTY_TERMINAL_PUNCTUATION = 28 ;
const integer PROPERTY_UNIFIED_IDEOGRAPH = 29 ;
const integer PROPERTY_UPPERCASE = 30 ;
const integer PROPERTY_WHITE_SPACE = 31 ;
const integer PROPERTY_XID_CONTINUE = 32 ;
const integer PROPERTY_XID_START = 33 ;
const integer PROPERTY_CASE_SENSITIVE = 34 ;
const integer PROPERTY_S_TERM = 35 ;
const integer PROPERTY_VARIATION_SELECTOR = 36 ;
const integer PROPERTY_NFD_INERT = 37 ;
const integer PROPERTY_NFKD_INERT = 38 ;
const integer PROPERTY_NFC_INERT = 39 ;
const integer PROPERTY_NFKC_INERT = 40 ;
const integer PROPERTY_SEGMENT_STARTER = 41 ;
const integer PROPERTY_PATTERN_SYNTAX = 42 ;
const integer PROPERTY_PATTERN_WHITE_SPACE = 43 ;
const integer PROPERTY_POSIX_ALNUM = 44 ;
const integer PROPERTY_POSIX_BLANK = 45 ;
const integer PROPERTY_POSIX_GRAPH = 46 ;
const integer PROPERTY_POSIX_PRINT = 47 ;
const integer PROPERTY_POSIX_XDIGIT = 48 ;
const integer PROPERTY_CASED = 49 ;
const integer PROPERTY_CASE_IGNORABLE = 50 ;
const integer PROPERTY_CHANGES_WHEN_LOWERCASED = 51 ;
const integer PROPERTY_CHANGES_WHEN_UPPERCASED = 52 ;
const integer PROPERTY_CHANGES_WHEN_TITLECASED = 53 ;
const integer PROPERTY_CHANGES_WHEN_CASEFOLDED = 54 ;
const integer PROPERTY_CHANGES_WHEN_CASEMAPPED = 55 ;
const integer PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED = 56 ;
const integer PROPERTY_BINARY_LIMIT = 57 ;
const integer PROPERTY_BIDI_CLASS = 4096 ;
const integer PROPERTY_INT_START = 4096 ;
const integer PROPERTY_BLOCK = 4097 ;
const integer PROPERTY_CANONICAL_COMBINING_CLASS = 4098 ;
const integer PROPERTY_DECOMPOSITION_TYPE = 4099 ;
const integer PROPERTY_EAST_ASIAN_WIDTH = 4100 ;
const integer PROPERTY_GENERAL_CATEGORY = 4101 ;
const integer PROPERTY_JOINING_GROUP = 4102 ;
const integer PROPERTY_JOINING_TYPE = 4103 ;
const integer PROPERTY_LINE_BREAK = 4104 ;
const integer PROPERTY_NUMERIC_TYPE = 4105 ;
const integer PROPERTY_SCRIPT = 4106 ;
const integer PROPERTY_HANGUL_SYLLABLE_TYPE = 4107 ;
const integer PROPERTY_NFD_QUICK_CHECK = 4108 ;
const integer PROPERTY_NFKD_QUICK_CHECK = 4109 ;
const integer PROPERTY_NFC_QUICK_CHECK = 4110 ;
const integer PROPERTY_NFKC_QUICK_CHECK = 4111 ;
const integer PROPERTY_LEAD_CANONICAL_COMBINING_CLASS = 4112 ;
const integer PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS = 4113 ;
const integer PROPERTY_GRAPHEME_CLUSTER_BREAK = 4114 ;
const integer PROPERTY_SENTENCE_BREAK = 4115 ;
const integer PROPERTY_WORD_BREAK = 4116 ;
const integer PROPERTY_BIDI_PAIRED_BRACKET_TYPE = 4117 ;
const integer PROPERTY_INT_LIMIT = 4118 ;
const integer PROPERTY_GENERAL_CATEGORY_MASK = 8192 ;
const integer PROPERTY_MASK_START = 8192 ;
const integer PROPERTY_MASK_LIMIT = 8193 ;
const integer PROPERTY_NUMERIC_VALUE = 12288 ;
const integer PROPERTY_DOUBLE_START = 12288 ;
const integer PROPERTY_DOUBLE_LIMIT = 12289 ;
const integer PROPERTY_AGE = 16384 ;
const integer PROPERTY_STRING_START = 16384 ;
const integer PROPERTY_BIDI_MIRRORING_GLYPH = 16385 ;
const integer PROPERTY_CASE_FOLDING = 16386 ;
const integer PROPERTY_ISO_COMMENT = 16387 ;
const integer PROPERTY_LOWERCASE_MAPPING = 16388 ;
const integer PROPERTY_NAME = 16389 ;
const integer PROPERTY_SIMPLE_CASE_FOLDING = 16390 ;
const integer PROPERTY_SIMPLE_LOWERCASE_MAPPING = 16391 ;
const integer PROPERTY_SIMPLE_TITLECASE_MAPPING = 16392 ;
const integer PROPERTY_SIMPLE_UPPERCASE_MAPPING = 16393 ;
const integer PROPERTY_TITLECASE_MAPPING = 16394 ;
const integer PROPERTY_UNICODE_1_NAME = 16395 ;
const integer PROPERTY_UPPERCASE_MAPPING = 16396 ;
const integer PROPERTY_BIDI_PAIRED_BRACKET = 16397 ;
const integer PROPERTY_STRING_LIMIT = 16398 ;
const integer PROPERTY_SCRIPT_EXTENSIONS = 28672 ;
const integer PROPERTY_OTHER_PROPERTY_START = 28672 ;
const integer PROPERTY_OTHER_PROPERTY_LIMIT = 28673 ;
const integer PROPERTY_INVALID_CODE = -1 ;
const integer CHAR_CATEGORY_UNASSIGNED = 0 ;
const integer CHAR_CATEGORY_GENERAL_OTHER_TYPES = 0 ;
const integer CHAR_CATEGORY_UPPERCASE_LETTER = 1 ;
const integer CHAR_CATEGORY_LOWERCASE_LETTER = 2 ;
const integer CHAR_CATEGORY_TITLECASE_LETTER = 3 ;
const integer CHAR_CATEGORY_MODIFIER_LETTER = 4 ;
const integer CHAR_CATEGORY_OTHER_LETTER = 5 ;
const integer CHAR_CATEGORY_NON_SPACING_MARK = 6 ;
const integer CHAR_CATEGORY_ENCLOSING_MARK = 7 ;
const integer CHAR_CATEGORY_COMBINING_SPACING_MARK = 8 ;
const integer CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER = 9 ;
const integer CHAR_CATEGORY_LETTER_NUMBER = 10 ;
const integer CHAR_CATEGORY_OTHER_NUMBER = 11 ;
const integer CHAR_CATEGORY_SPACE_SEPARATOR = 12 ;
const integer CHAR_CATEGORY_LINE_SEPARATOR = 13 ;
const integer CHAR_CATEGORY_PARAGRAPH_SEPARATOR = 14 ;
const integer CHAR_CATEGORY_CONTROL_CHAR = 15 ;
const integer CHAR_CATEGORY_FORMAT_CHAR = 16 ;
const integer CHAR_CATEGORY_PRIVATE_USE_CHAR = 17 ;
const integer CHAR_CATEGORY_SURROGATE = 18 ;
const integer CHAR_CATEGORY_DASH_PUNCTUATION = 19 ;
const integer CHAR_CATEGORY_START_PUNCTUATION = 20 ;
const integer CHAR_CATEGORY_END_PUNCTUATION = 21 ;
const integer CHAR_CATEGORY_CONNECTOR_PUNCTUATION = 22 ;
const integer CHAR_CATEGORY_OTHER_PUNCTUATION = 23 ;
const integer CHAR_CATEGORY_MATH_SYMBOL = 24 ;
const integer CHAR_CATEGORY_CURRENCY_SYMBOL = 25 ;
const integer CHAR_CATEGORY_MODIFIER_SYMBOL = 26 ;
const integer CHAR_CATEGORY_OTHER_SYMBOL = 27 ;
const integer CHAR_CATEGORY_INITIAL_PUNCTUATION = 28 ;
const integer CHAR_CATEGORY_FINAL_PUNCTUATION = 29 ;
const integer CHAR_CATEGORY_CHAR_CATEGORY_COUNT = 30 ;
const integer CHAR_DIRECTION_LEFT_TO_RIGHT = 0 ;
const integer CHAR_DIRECTION_RIGHT_TO_LEFT = 1 ;
const integer CHAR_DIRECTION_EUROPEAN_NUMBER = 2 ;
const integer CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR = 3 ;
const integer CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR = 4 ;
const integer CHAR_DIRECTION_ARABIC_NUMBER = 5 ;
const integer CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR = 6 ;
const integer CHAR_DIRECTION_BLOCK_SEPARATOR = 7 ;
const integer CHAR_DIRECTION_SEGMENT_SEPARATOR = 8 ;
const integer CHAR_DIRECTION_WHITE_SPACE_NEUTRAL = 9 ;
const integer CHAR_DIRECTION_OTHER_NEUTRAL = 10 ;
const integer CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING = 11 ;
const integer CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE = 12 ;
const integer CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC = 13 ;
const integer CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING = 14 ;
const integer CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE = 15 ;
const integer CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT = 16 ;
const integer CHAR_DIRECTION_DIR_NON_SPACING_MARK = 17 ;
const integer CHAR_DIRECTION_BOUNDARY_NEUTRAL = 18 ;
const integer CHAR_DIRECTION_FIRST_STRONG_ISOLATE = 19 ;
const integer CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE = 20 ;
const integer CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE = 21 ;
const integer CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE = 22 ;
const integer CHAR_DIRECTION_CHAR_DIRECTION_COUNT = 23 ;
const integer BLOCK_CODE_NO_BLOCK = 0 ;
const integer BLOCK_CODE_BASIC_LATIN = 1 ;
const integer BLOCK_CODE_LATIN_1_SUPPLEMENT = 2 ;
const integer BLOCK_CODE_LATIN_EXTENDED_A = 3 ;
const integer BLOCK_CODE_LATIN_EXTENDED_B = 4 ;
const integer BLOCK_CODE_IPA_EXTENSIONS = 5 ;
const integer BLOCK_CODE_SPACING_MODIFIER_LETTERS = 6 ;
const integer BLOCK_CODE_COMBINING_DIACRITICAL_MARKS = 7 ;
const integer BLOCK_CODE_GREEK = 8 ;
const integer BLOCK_CODE_CYRILLIC = 9 ;
const integer BLOCK_CODE_ARMENIAN = 10 ;
const integer BLOCK_CODE_HEBREW = 11 ;
const integer BLOCK_CODE_ARABIC = 12 ;
const integer BLOCK_CODE_SYRIAC = 13 ;
const integer BLOCK_CODE_THAANA = 14 ;
const integer BLOCK_CODE_DEVANAGARI = 15 ;
const integer BLOCK_CODE_BENGALI = 16 ;
const integer BLOCK_CODE_GURMUKHI = 17 ;
const integer BLOCK_CODE_GUJARATI = 18 ;
const integer BLOCK_CODE_ORIYA = 19 ;
const integer BLOCK_CODE_TAMIL = 20 ;
const integer BLOCK_CODE_TELUGU = 21 ;
const integer BLOCK_CODE_KANNADA = 22 ;
const integer BLOCK_CODE_MALAYALAM = 23 ;
const integer BLOCK_CODE_SINHALA = 24 ;
const integer BLOCK_CODE_THAI = 25 ;
const integer BLOCK_CODE_LAO = 26 ;
const integer BLOCK_CODE_TIBETAN = 27 ;
const integer BLOCK_CODE_MYANMAR = 28 ;
const integer BLOCK_CODE_GEORGIAN = 29 ;
const integer BLOCK_CODE_HANGUL_JAMO = 30 ;
const integer BLOCK_CODE_ETHIOPIC = 31 ;
const integer BLOCK_CODE_CHEROKEE = 32 ;
const integer BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS = 33 ;
const integer BLOCK_CODE_OGHAM = 34 ;
const integer BLOCK_CODE_RUNIC = 35 ;
const integer BLOCK_CODE_KHMER = 36 ;
const integer BLOCK_CODE_MONGOLIAN = 37 ;
const integer BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL = 38 ;
const integer BLOCK_CODE_GREEK_EXTENDED = 39 ;
const integer BLOCK_CODE_GENERAL_PUNCTUATION = 40 ;
const integer BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS = 41 ;
const integer BLOCK_CODE_CURRENCY_SYMBOLS = 42 ;
const integer BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS = 43 ;
const integer BLOCK_CODE_LETTERLIKE_SYMBOLS = 44 ;
const integer BLOCK_CODE_NUMBER_FORMS = 45 ;
const integer BLOCK_CODE_ARROWS = 46 ;
const integer BLOCK_CODE_MATHEMATICAL_OPERATORS = 47 ;
const integer BLOCK_CODE_MISCELLANEOUS_TECHNICAL = 48 ;
const integer BLOCK_CODE_CONTROL_PICTURES = 49 ;
const integer BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION = 50 ;
const integer BLOCK_CODE_ENCLOSED_ALPHANUMERICS = 51 ;
const integer BLOCK_CODE_BOX_DRAWING = 52 ;
const integer BLOCK_CODE_BLOCK_ELEMENTS = 53 ;
const integer BLOCK_CODE_GEOMETRIC_SHAPES = 54 ;
const integer BLOCK_CODE_MISCELLANEOUS_SYMBOLS = 55 ;
const integer BLOCK_CODE_DINGBATS = 56 ;
const integer BLOCK_CODE_BRAILLE_PATTERNS = 57 ;
const integer BLOCK_CODE_CJK_RADICALS_SUPPLEMENT = 58 ;
const integer BLOCK_CODE_KANGXI_RADICALS = 59 ;
const integer BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS = 60 ;
const integer BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION = 61 ;
const integer BLOCK_CODE_HIRAGANA = 62 ;
const integer BLOCK_CODE_KATAKANA = 63 ;
const integer BLOCK_CODE_BOPOMOFO = 64 ;
const integer BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO = 65 ;
const integer BLOCK_CODE_KANBUN = 66 ;
const integer BLOCK_CODE_BOPOMOFO_EXTENDED = 67 ;
const integer BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS = 68 ;
const integer BLOCK_CODE_CJK_COMPATIBILITY = 69 ;
const integer BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A = 70 ;
const integer BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS = 71 ;
const integer BLOCK_CODE_YI_SYLLABLES = 72 ;
const integer BLOCK_CODE_YI_RADICALS = 73 ;
const integer BLOCK_CODE_HANGUL_SYLLABLES = 74 ;
const integer BLOCK_CODE_HIGH_SURROGATES = 75 ;
const integer BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES = 76 ;
const integer BLOCK_CODE_LOW_SURROGATES = 77 ;
const integer BLOCK_CODE_PRIVATE_USE_AREA = 78 ;
const integer BLOCK_CODE_PRIVATE_USE = 78 ;
const integer BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS = 79 ;
const integer BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS = 80 ;
const integer BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A = 81 ;
const integer BLOCK_CODE_COMBINING_HALF_MARKS = 82 ;
const integer BLOCK_CODE_CJK_COMPATIBILITY_FORMS = 83 ;
const integer BLOCK_CODE_SMALL_FORM_VARIANTS = 84 ;
const integer BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B = 85 ;
const integer BLOCK_CODE_SPECIALS = 86 ;
const integer BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS = 87 ;
const integer BLOCK_CODE_OLD_ITALIC = 88 ;
const integer BLOCK_CODE_GOTHIC = 89 ;
const integer BLOCK_CODE_DESERET = 90 ;
const integer BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS = 91 ;
const integer BLOCK_CODE_MUSICAL_SYMBOLS = 92 ;
const integer BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 93 ;
const integer BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B = 94 ;
const integer BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT = 95 ;
const integer BLOCK_CODE_TAGS = 96 ;
const integer BLOCK_CODE_CYRILLIC_SUPPLEMENT = 97 ;
const integer BLOCK_CODE_CYRILLIC_SUPPLEMENTARY = 97 ;
const integer BLOCK_CODE_TAGALOG = 98 ;
const integer BLOCK_CODE_HANUNOO = 99 ;
const integer BLOCK_CODE_BUHID = 100 ;
const integer BLOCK_CODE_TAGBANWA = 101 ;
const integer BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A = 102 ;
const integer BLOCK_CODE_SUPPLEMENTAL_ARROWS_A = 103 ;
const integer BLOCK_CODE_SUPPLEMENTAL_ARROWS_B = 104 ;
const integer BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B = 105 ;
const integer BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS = 106 ;
const integer BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS = 107 ;
const integer BLOCK_CODE_VARIATION_SELECTORS = 108 ;
const integer BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A = 109 ;
const integer BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B = 110 ;
const integer BLOCK_CODE_LIMBU = 111 ;
const integer BLOCK_CODE_TAI_LE = 112 ;
const integer BLOCK_CODE_KHMER_SYMBOLS = 113 ;
const integer BLOCK_CODE_PHONETIC_EXTENSIONS = 114 ;
const integer BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS = 115 ;
const integer BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS = 116 ;
const integer BLOCK_CODE_LINEAR_B_SYLLABARY = 117 ;
const integer BLOCK_CODE_LINEAR_B_IDEOGRAMS = 118 ;
const integer BLOCK_CODE_AEGEAN_NUMBERS = 119 ;
const integer BLOCK_CODE_UGARITIC = 120 ;
const integer BLOCK_CODE_SHAVIAN = 121 ;
const integer BLOCK_CODE_OSMANYA = 122 ;
const integer BLOCK_CODE_CYPRIOT_SYLLABARY = 123 ;
const integer BLOCK_CODE_TAI_XUAN_JING_SYMBOLS = 124 ;
const integer BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT = 125 ;
const integer BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION = 126 ;
const integer BLOCK_CODE_ANCIENT_GREEK_NUMBERS = 127 ;
const integer BLOCK_CODE_ARABIC_SUPPLEMENT = 128 ;
const integer BLOCK_CODE_BUGINESE = 129 ;
const integer BLOCK_CODE_CJK_STROKES = 130 ;
const integer BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT = 131 ;
const integer BLOCK_CODE_COPTIC = 132 ;
const integer BLOCK_CODE_ETHIOPIC_EXTENDED = 133 ;
const integer BLOCK_CODE_ETHIOPIC_SUPPLEMENT = 134 ;
const integer BLOCK_CODE_GEORGIAN_SUPPLEMENT = 135 ;
const integer BLOCK_CODE_GLAGOLITIC = 136 ;
const integer BLOCK_CODE_KHAROSHTHI = 137 ;
const integer BLOCK_CODE_MODIFIER_TONE_LETTERS = 138 ;
const integer BLOCK_CODE_NEW_TAI_LUE = 139 ;
const integer BLOCK_CODE_OLD_PERSIAN = 140 ;
const integer BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT = 141 ;
const integer BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION = 142 ;
const integer BLOCK_CODE_SYLOTI_NAGRI = 143 ;
const integer BLOCK_CODE_TIFINAGH = 144 ;
const integer BLOCK_CODE_VERTICAL_FORMS = 145 ;
const integer BLOCK_CODE_NKO = 146 ;
const integer BLOCK_CODE_BALINESE = 147 ;
const integer BLOCK_CODE_LATIN_EXTENDED_C = 148 ;
const integer BLOCK_CODE_LATIN_EXTENDED_D = 149 ;
const integer BLOCK_CODE_PHAGS_PA = 150 ;
const integer BLOCK_CODE_PHOENICIAN = 151 ;
const integer BLOCK_CODE_CUNEIFORM = 152 ;
const integer BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION = 153 ;
const integer BLOCK_CODE_COUNTING_ROD_NUMERALS = 154 ;
const integer BLOCK_CODE_SUNDANESE = 155 ;
const integer BLOCK_CODE_LEPCHA = 156 ;
const integer BLOCK_CODE_OL_CHIKI = 157 ;
const integer BLOCK_CODE_CYRILLIC_EXTENDED_A = 158 ;
const integer BLOCK_CODE_VAI = 159 ;
const integer BLOCK_CODE_CYRILLIC_EXTENDED_B = 160 ;
const integer BLOCK_CODE_SAURASHTRA = 161 ;
const integer BLOCK_CODE_KAYAH_LI = 162 ;
const integer BLOCK_CODE_REJANG = 163 ;
const integer BLOCK_CODE_CHAM = 164 ;
const integer BLOCK_CODE_ANCIENT_SYMBOLS = 165 ;
const integer BLOCK_CODE_PHAISTOS_DISC = 166 ;
const integer BLOCK_CODE_LYCIAN = 167 ;
const integer BLOCK_CODE_CARIAN = 168 ;
const integer BLOCK_CODE_LYDIAN = 169 ;
const integer BLOCK_CODE_MAHJONG_TILES = 170 ;
const integer BLOCK_CODE_DOMINO_TILES = 171 ;
const integer BLOCK_CODE_SAMARITAN = 172 ;
const integer BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED = 173 ;
const integer BLOCK_CODE_TAI_THAM = 174 ;
const integer BLOCK_CODE_VEDIC_EXTENSIONS = 175 ;
const integer BLOCK_CODE_LISU = 176 ;
const integer BLOCK_CODE_BAMUM = 177 ;
const integer BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS = 178 ;
const integer BLOCK_CODE_DEVANAGARI_EXTENDED = 179 ;
const integer BLOCK_CODE_HANGUL_JAMO_EXTENDED_A = 180 ;
const integer BLOCK_CODE_JAVANESE = 181 ;
const integer BLOCK_CODE_MYANMAR_EXTENDED_A = 182 ;
const integer BLOCK_CODE_TAI_VIET = 183 ;
const integer BLOCK_CODE_MEETEI_MAYEK = 184 ;
const integer BLOCK_CODE_HANGUL_JAMO_EXTENDED_B = 185 ;
const integer BLOCK_CODE_IMPERIAL_ARAMAIC = 186 ;
const integer BLOCK_CODE_OLD_SOUTH_ARABIAN = 187 ;
const integer BLOCK_CODE_AVESTAN = 188 ;
const integer BLOCK_CODE_INSCRIPTIONAL_PARTHIAN = 189 ;
const integer BLOCK_CODE_INSCRIPTIONAL_PAHLAVI = 190 ;
const integer BLOCK_CODE_OLD_TURKIC = 191 ;
const integer BLOCK_CODE_RUMI_NUMERAL_SYMBOLS = 192 ;
const integer BLOCK_CODE_KAITHI = 193 ;
const integer BLOCK_CODE_EGYPTIAN_HIEROGLYPHS = 194 ;
const integer BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT = 195 ;
const integer BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT = 196 ;
const integer BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C = 197 ;
const integer BLOCK_CODE_MANDAIC = 198 ;
const integer BLOCK_CODE_BATAK = 199 ;
const integer BLOCK_CODE_ETHIOPIC_EXTENDED_A = 200 ;
const integer BLOCK_CODE_BRAHMI = 201 ;
const integer BLOCK_CODE_BAMUM_SUPPLEMENT = 202 ;
const integer BLOCK_CODE_KANA_SUPPLEMENT = 203 ;
const integer BLOCK_CODE_PLAYING_CARDS = 204 ;
const integer BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS = 205 ;
const integer BLOCK_CODE_EMOTICONS = 206 ;
const integer BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS = 207 ;
const integer BLOCK_CODE_ALCHEMICAL_SYMBOLS = 208 ;
const integer BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D = 209 ;
const integer BLOCK_CODE_ARABIC_EXTENDED_A = 210 ;
const integer BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS = 211 ;
const integer BLOCK_CODE_CHAKMA = 212 ;
const integer BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS = 213 ;
const integer BLOCK_CODE_MEROITIC_CURSIVE = 214 ;
const integer BLOCK_CODE_MEROITIC_HIEROGLYPHS = 215 ;
const integer BLOCK_CODE_MIAO = 216 ;
const integer BLOCK_CODE_SHARADA = 217 ;
const integer BLOCK_CODE_SORA_SOMPENG = 218 ;
const integer BLOCK_CODE_SUNDANESE_SUPPLEMENT = 219 ;
const integer BLOCK_CODE_TAKRI = 220 ;
const integer BLOCK_CODE_COUNT = 221 ;
const integer BLOCK_CODE_INVALID_CODE = -1 ;
const integer BPT_NONE = 0 ;
const integer BPT_OPEN = 1 ;
const integer BPT_CLOSE = 2 ;
const integer BPT_COUNT = 3 ;
const integer EA_NEUTRAL = 0 ;
const integer EA_AMBIGUOUS = 1 ;
const integer EA_HALFWIDTH = 2 ;
const integer EA_FULLWIDTH = 3 ;
const integer EA_NARROW = 4 ;
const integer EA_WIDE = 5 ;
const integer EA_COUNT = 6 ;
const integer UNICODE_CHAR_NAME = 0 ;
const integer UNICODE_10_CHAR_NAME = 1 ;
const integer EXTENDED_CHAR_NAME = 2 ;
const integer CHAR_NAME_ALIAS = 3 ;
const integer CHAR_NAME_CHOICE_COUNT = 4 ;
const integer SHORT_PROPERTY_NAME = 0 ;
const integer LONG_PROPERTY_NAME = 1 ;
const integer PROPERTY_NAME_CHOICE_COUNT = 2 ;
const integer DT_NONE = 0 ;
const integer DT_CANONICAL = 1 ;
const integer DT_COMPAT = 2 ;
const integer DT_CIRCLE = 3 ;
const integer DT_FINAL = 4 ;
const integer DT_FONT = 5 ;
const integer DT_FRACTION = 6 ;
const integer DT_INITIAL = 7 ;
const integer DT_ISOLATED = 8 ;
const integer DT_MEDIAL = 9 ;
const integer DT_NARROW = 10 ;
const integer DT_NOBREAK = 11 ;
const integer DT_SMALL = 12 ;
const integer DT_SQUARE = 13 ;
const integer DT_SUB = 14 ;
const integer DT_SUPER = 15 ;
const integer DT_VERTICAL = 16 ;
const integer DT_WIDE = 17 ;
const integer DT_COUNT = 18 ;
const integer JT_NON_JOINING = 0 ;
const integer JT_JOIN_CAUSING = 1 ;
const integer JT_DUAL_JOINING = 2 ;
const integer JT_LEFT_JOINING = 3 ;
const integer JT_RIGHT_JOINING = 4 ;
const integer JT_TRANSPARENT = 5 ;
const integer JT_COUNT = 6 ;
const integer JG_NO_JOINING_GROUP = 0 ;
const integer JG_AIN = 1 ;
const integer JG_ALAPH = 2 ;
const integer JG_ALEF = 3 ;
const integer JG_BEH = 4 ;
const integer JG_BETH = 5 ;
const integer JG_DAL = 6 ;
const integer JG_DALATH_RISH = 7 ;
const integer JG_E = 8 ;
const integer JG_FEH = 9 ;
const integer JG_FINAL_SEMKATH = 10 ;
const integer JG_GAF = 11 ;
const integer JG_GAMAL = 12 ;
const integer JG_HAH = 13 ;
const integer JG_TEH_MARBUTA_GOAL = 14 ;
const integer JG_HAMZA_ON_HEH_GOAL = 14 ;
const integer JG_HE = 15 ;
const integer JG_HEH = 16 ;
const integer JG_HEH_GOAL = 17 ;
const integer JG_HETH = 18 ;
const integer JG_KAF = 19 ;
const integer JG_KAPH = 20 ;
const integer JG_KNOTTED_HEH = 21 ;
const integer JG_LAM = 22 ;
const integer JG_LAMADH = 23 ;
const integer JG_MEEM = 24 ;
const integer JG_MIM = 25 ;
const integer JG_NOON = 26 ;
const integer JG_NUN = 27 ;
const integer JG_PE = 28 ;
const integer JG_QAF = 29 ;
const integer JG_QAPH = 30 ;
const integer JG_REH = 31 ;
const integer JG_REVERSED_PE = 32 ;
const integer JG_SAD = 33 ;
const integer JG_SADHE = 34 ;
const integer JG_SEEN = 35 ;
const integer JG_SEMKATH = 36 ;
const integer JG_SHIN = 37 ;
const integer JG_SWASH_KAF = 38 ;
const integer JG_SYRIAC_WAW = 39 ;
const integer JG_TAH = 40 ;
const integer JG_TAW = 41 ;
const integer JG_TEH_MARBUTA = 42 ;
const integer JG_TETH = 43 ;
const integer JG_WAW = 44 ;
const integer JG_YEH = 45 ;
const integer JG_YEH_BARREE = 46 ;
const integer JG_YEH_WITH_TAIL = 47 ;
const integer JG_YUDH = 48 ;
const integer JG_YUDH_HE = 49 ;
const integer JG_ZAIN = 50 ;
const integer JG_FE = 51 ;
const integer JG_KHAPH = 52 ;
const integer JG_ZHAIN = 53 ;
const integer JG_BURUSHASKI_YEH_BARREE = 54 ;
const integer JG_FARSI_YEH = 55 ;
const integer JG_NYA = 56 ;
const integer JG_ROHINGYA_YEH = 57 ;
const integer JG_COUNT = 58 ;
const integer GCB_OTHER = 0 ;
const integer GCB_CONTROL = 1 ;
const integer GCB_CR = 2 ;
const integer GCB_EXTEND = 3 ;
const integer GCB_L = 4 ;
const integer GCB_LF = 5 ;
const integer GCB_LV = 6 ;
const integer GCB_LVT = 7 ;
const integer GCB_T = 8 ;
const integer GCB_V = 9 ;
const integer GCB_SPACING_MARK = 10 ;
const integer GCB_PREPEND = 11 ;
const integer GCB_REGIONAL_INDICATOR = 12 ;
const integer GCB_COUNT = 13 ;
const integer WB_OTHER = 0 ;
const integer WB_ALETTER = 1 ;
const integer WB_FORMAT = 2 ;
const integer WB_KATAKANA = 3 ;
const integer WB_MIDLETTER = 4 ;
const integer WB_MIDNUM = 5 ;
const integer WB_NUMERIC = 6 ;
const integer WB_EXTENDNUMLET = 7 ;
const integer WB_CR = 8 ;
const integer WB_EXTEND = 9 ;
const integer WB_LF = 10 ;
const integer WB_MIDNUMLET = 11 ;
const integer WB_NEWLINE = 12 ;
const integer WB_REGIONAL_INDICATOR = 13 ;
const integer WB_HEBREW_LETTER = 14 ;
const integer WB_SINGLE_QUOTE = 15 ;
const integer WB_DOUBLE_QUOTE = 16 ;
const integer WB_COUNT = 17 ;
const integer SB_OTHER = 0 ;
const integer SB_ATERM = 1 ;
const integer SB_CLOSE = 2 ;
const integer SB_FORMAT = 3 ;
const integer SB_LOWER = 4 ;
const integer SB_NUMERIC = 5 ;
const integer SB_OLETTER = 6 ;
const integer SB_SEP = 7 ;
const integer SB_SP = 8 ;
const integer SB_STERM = 9 ;
const integer SB_UPPER = 10 ;
const integer SB_CR = 11 ;
const integer SB_EXTEND = 12 ;
const integer SB_LF = 13 ;
const integer SB_SCONTINUE = 14 ;
const integer SB_COUNT = 15 ;
const integer LB_UNKNOWN = 0 ;
const integer LB_AMBIGUOUS = 1 ;
const integer LB_ALPHABETIC = 2 ;
const integer LB_BREAK_BOTH = 3 ;
const integer LB_BREAK_AFTER = 4 ;
const integer LB_BREAK_BEFORE = 5 ;
const integer LB_MANDATORY_BREAK = 6 ;
const integer LB_CONTINGENT_BREAK = 7 ;
const integer LB_CLOSE_PUNCTUATION = 8 ;
const integer LB_COMBINING_MARK = 9 ;
const integer LB_CARRIAGE_RETURN = 10 ;
const integer LB_EXCLAMATION = 11 ;
const integer LB_GLUE = 12 ;
const integer LB_HYPHEN = 13 ;
const integer LB_IDEOGRAPHIC = 14 ;
const integer LB_INSEPARABLE = 15 ;
const integer LB_INSEPERABLE = 15 ;
const integer LB_INFIX_NUMERIC = 16 ;
const integer LB_LINE_FEED = 17 ;
const integer LB_NONSTARTER = 18 ;
const integer LB_NUMERIC = 19 ;
const integer LB_OPEN_PUNCTUATION = 20 ;
const integer LB_POSTFIX_NUMERIC = 21 ;
const integer LB_PREFIX_NUMERIC = 22 ;
const integer LB_QUOTATION = 23 ;
const integer LB_COMPLEX_CONTEXT = 24 ;
const integer LB_SURROGATE = 25 ;
const integer LB_SPACE = 26 ;
const integer LB_BREAK_SYMBOLS = 27 ;
const integer LB_ZWSPACE = 28 ;
const integer LB_NEXT_LINE = 29 ;
const integer LB_WORD_JOINER = 30 ;
const integer LB_H2 = 31 ;
const integer LB_H3 = 32 ;
const integer LB_JL = 33 ;
const integer LB_JT = 34 ;
const integer LB_JV = 35 ;
const integer LB_CLOSE_PARENTHESIS = 36 ;
const integer LB_CONDITIONAL_JAPANESE_STARTER = 37 ;
const integer LB_HEBREW_LETTER = 38 ;
const integer LB_REGIONAL_INDICATOR = 39 ;
const integer LB_COUNT = 40 ;
const integer NT_NONE = 0 ;
const integer NT_DECIMAL = 1 ;
const integer NT_DIGIT = 2 ;
const integer NT_NUMERIC = 3 ;
const integer NT_COUNT = 4 ;
const integer HST_NOT_APPLICABLE = 0 ;
const integer HST_LEADING_JAMO = 1 ;
const integer HST_VOWEL_JAMO = 2 ;
const integer HST_TRAILING_JAMO = 3 ;
const integer HST_LV_SYLLABLE = 4 ;
const integer HST_LVT_SYLLABLE = 5 ;
const integer HST_COUNT = 6 ;
/* Methods */
public static charAge ( mixed $codepoint ) : array
public static charDigitValue ( mixed $codepoint ) : int
public static charDirection ( mixed $codepoint ) : int
public static charFromName ( string $characterName [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : int
public static charMirror ( mixed $codepoint ) : mixed
public static charName ( mixed $codepoint [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : string
public static charType ( mixed $codepoint ) : int
public static chr ( mixed $codepoint ) : string
public static digit ( string $codepoint [, int $radix = 10 ] ) : int
public static enumCharNames ( mixed $start , mixed $limit , callable $callback [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : void
public static enumCharTypes ( callable $callback ) : void
public static foldCase ( mixed $codepoint [, int $options = IntlChar::FOLD_CASE_DEFAULT ] ) : mixed
public static forDigit ( int $digit [, int $radix = 10 ] ) : int
public static getBidiPairedBracket ( mixed $codepoint ) : mixed
public static getBlockCode ( mixed $codepoint ) : int
public static getCombiningClass ( mixed $codepoint ) : int
public static getFC_NFKC_Closure ( mixed $codepoint ) : string
public static getIntPropertyMaxValue ( int $property ) : int
public static getIntPropertyMinValue ( int $property ) : int
public static getIntPropertyValue ( mixed $codepoint , int $property ) : int
public static getNumericValue ( mixed $codepoint ) : float
public static getPropertyEnum ( string $alias ) : int
public static getPropertyName ( int $property [, int $nameChoice = IntlChar::LONG_PROPERTY_NAME ] ) : string
public static getPropertyValueEnum ( int $property , string $name ) : int
public static getPropertyValueName ( int $property , int $value [, int $nameChoice = IntlChar::LONG_PROPERTY_NAME ] ) : string
public static getUnicodeVersion ( void ) : array
public static hasBinaryProperty ( mixed $codepoint , int $property ) : bool
public static isalnum ( mixed $codepoint ) : bool
public static isalpha ( mixed $codepoint ) : bool
public static isbase ( mixed $codepoint ) : bool
public static isblank ( mixed $codepoint ) : bool
public static iscntrl ( mixed $codepoint ) : bool
public static isdefined ( mixed $codepoint ) : bool
public static isdigit ( mixed $codepoint ) : bool
public static isgraph ( mixed $codepoint ) : bool
public static isIDIgnorable ( mixed $codepoint ) : bool
public static isIDPart ( mixed $codepoint ) : bool
public static isIDStart ( mixed $codepoint ) : bool
public static isISOControl ( mixed $codepoint ) : bool
public static isJavaIDPart ( mixed $codepoint ) : bool
public static isJavaIDStart ( mixed $codepoint ) : bool
public static isJavaSpaceChar ( mixed $codepoint ) : bool
public static islower ( mixed $codepoint ) : bool
public static isMirrored ( mixed $codepoint ) : bool
public static isprint ( mixed $codepoint ) : bool
public static ispunct ( mixed $codepoint ) : bool
public static isspace ( mixed $codepoint ) : bool
public static istitle ( mixed $codepoint ) : bool
public static isUAlphabetic ( mixed $codepoint ) : bool
public static isULowercase ( mixed $codepoint ) : bool
public static isupper ( mixed $codepoint ) : bool
public static isUUppercase ( mixed $codepoint ) : bool
public static isUWhiteSpace ( mixed $codepoint ) : bool
public static isWhitespace ( mixed $codepoint ) : bool
public static isxdigit ( mixed $codepoint ) : bool
public static ord ( mixed $character ) : int
public static tolower ( mixed $codepoint ) : mixed
public static totitle ( mixed $codepoint ) : mixed
public static toupper ( mixed $codepoint ) : mixed
}

Predefined Constants

IntlChar::UNICODE_VERSION

IntlChar::CODEPOINT_MIN

IntlChar::CODEPOINT_MAX

IntlChar::NO_NUMERIC_VALUE

Special value that is returned by IntlChar::getNumericValue() when no numeric value is defined for a code point.

IntlChar::PROPERTY_ALPHABETIC

IntlChar::PROPERTY_BINARY_START

IntlChar::PROPERTY_ASCII_HEX_DIGIT

IntlChar::PROPERTY_BIDI_CONTROL

IntlChar::PROPERTY_BIDI_MIRRORED

IntlChar::PROPERTY_DASH

IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT

IntlChar::PROPERTY_DEPRECATED

IntlChar::PROPERTY_DIACRITIC

IntlChar::PROPERTY_EXTENDER

IntlChar::PROPERTY_FULL_COMPOSITION_EXCLUSION

IntlChar::PROPERTY_GRAPHEME_BASE

IntlChar::PROPERTY_GRAPHEME_EXTEND

IntlChar::PROPERTY_HEX_DIGIT

IntlChar::PROPERTY_HYPHEN

IntlChar::PROPERTY_ID_CONTINUE

IntlChar::PROPERTY_ID_START

IntlChar::PROPERTY_IDEOGRAPHIC

IntlChar::PROPERTY_IDS_BINARY_OPERATOR

IntlChar::PROPERTY_IDS_TRINARY_OPERATOR

IntlChar::PROPERTY_JOIN_CONTROL

IntlChar::PROPERTY_LOGICAL_ORDER_EXCEPTION

IntlChar::PROPERTY_LOWERCASE

IntlChar::PROPERTY_MATH

IntlChar::PROPERTY_NONCHARACTER_CODE_POINT

IntlChar::PROPERTY_QUOTATION_MARK

IntlChar::PROPERTY_RADICAL

IntlChar::PROPERTY_SOFT_DOTTED

IntlChar::PROPERTY_TERMINAL_PUNCTUATION

IntlChar::PROPERTY_UNIFIED_IDEOGRAPH

IntlChar::PROPERTY_UPPERCASE

IntlChar::PROPERTY_WHITE_SPACE

IntlChar::PROPERTY_XID_CONTINUE

IntlChar::PROPERTY_XID_START

IntlChar::PROPERTY_CASE_SENSITIVE

IntlChar::PROPERTY_S_TERM

IntlChar::PROPERTY_VARIATION_SELECTOR

IntlChar::PROPERTY_NFD_INERT

IntlChar::PROPERTY_NFKD_INERT

IntlChar::PROPERTY_NFC_INERT

IntlChar::PROPERTY_NFKC_INERT

IntlChar::PROPERTY_SEGMENT_STARTER

IntlChar::PROPERTY_PATTERN_SYNTAX

IntlChar::PROPERTY_PATTERN_WHITE_SPACE

IntlChar::PROPERTY_POSIX_ALNUM

IntlChar::PROPERTY_POSIX_BLANK

IntlChar::PROPERTY_POSIX_GRAPH

IntlChar::PROPERTY_POSIX_PRINT

IntlChar::PROPERTY_POSIX_XDIGIT

IntlChar::PROPERTY_CASED

IntlChar::PROPERTY_CASE_IGNORABLE

IntlChar::PROPERTY_CHANGES_WHEN_LOWERCASED

IntlChar::PROPERTY_CHANGES_WHEN_UPPERCASED

IntlChar::PROPERTY_CHANGES_WHEN_TITLECASED

IntlChar::PROPERTY_CHANGES_WHEN_CASEFOLDED

IntlChar::PROPERTY_CHANGES_WHEN_CASEMAPPED

IntlChar::PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED

IntlChar::PROPERTY_BINARY_LIMIT

IntlChar::PROPERTY_BIDI_CLASS

IntlChar::PROPERTY_INT_START

IntlChar::PROPERTY_BLOCK

IntlChar::PROPERTY_CANONICAL_COMBINING_CLASS

IntlChar::PROPERTY_DECOMPOSITION_TYPE

IntlChar::PROPERTY_EAST_ASIAN_WIDTH

IntlChar::PROPERTY_GENERAL_CATEGORY

IntlChar::PROPERTY_JOINING_GROUP

IntlChar::PROPERTY_JOINING_TYPE

IntlChar::PROPERTY_LINE_BREAK

IntlChar::PROPERTY_NUMERIC_TYPE

IntlChar::PROPERTY_SCRIPT

IntlChar::PROPERTY_HANGUL_SYLLABLE_TYPE

IntlChar::PROPERTY_NFD_QUICK_CHECK

IntlChar::PROPERTY_NFKD_QUICK_CHECK

IntlChar::PROPERTY_NFC_QUICK_CHECK

IntlChar::PROPERTY_NFKC_QUICK_CHECK

IntlChar::PROPERTY_LEAD_CANONICAL_COMBINING_CLASS

IntlChar::PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS

IntlChar::PROPERTY_GRAPHEME_CLUSTER_BREAK

IntlChar::PROPERTY_SENTENCE_BREAK

IntlChar::PROPERTY_WORD_BREAK

IntlChar::PROPERTY_BIDI_PAIRED_BRACKET_TYPE

IntlChar::PROPERTY_INT_LIMIT

IntlChar::PROPERTY_GENERAL_CATEGORY_MASK

IntlChar::PROPERTY_MASK_START

IntlChar::PROPERTY_MASK_LIMIT

IntlChar::PROPERTY_NUMERIC_VALUE

IntlChar::PROPERTY_DOUBLE_START

IntlChar::PROPERTY_DOUBLE_LIMIT

IntlChar::PROPERTY_AGE

IntlChar::PROPERTY_STRING_START

IntlChar::PROPERTY_BIDI_MIRRORING_GLYPH

IntlChar::PROPERTY_CASE_FOLDING

IntlChar::PROPERTY_ISO_COMMENT

IntlChar::PROPERTY_LOWERCASE_MAPPING

IntlChar::PROPERTY_NAME

IntlChar::PROPERTY_SIMPLE_CASE_FOLDING

IntlChar::PROPERTY_SIMPLE_LOWERCASE_MAPPING

IntlChar::PROPERTY_SIMPLE_TITLECASE_MAPPING

IntlChar::PROPERTY_SIMPLE_UPPERCASE_MAPPING

IntlChar::PROPERTY_TITLECASE_MAPPING

IntlChar::PROPERTY_UNICODE_1_NAME

IntlChar::PROPERTY_UPPERCASE_MAPPING

IntlChar::PROPERTY_BIDI_PAIRED_BRACKET

IntlChar::PROPERTY_STRING_LIMIT

IntlChar::PROPERTY_SCRIPT_EXTENSIONS

IntlChar::PROPERTY_OTHER_PROPERTY_START

IntlChar::PROPERTY_OTHER_PROPERTY_LIMIT

IntlChar::PROPERTY_INVALID_CODE

IntlChar::CHAR_CATEGORY_UNASSIGNED

IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES

IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER

IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER

IntlChar::CHAR_CATEGORY_TITLECASE_LETTER

IntlChar::CHAR_CATEGORY_MODIFIER_LETTER

IntlChar::CHAR_CATEGORY_OTHER_LETTER

IntlChar::CHAR_CATEGORY_NON_SPACING_MARK

IntlChar::CHAR_CATEGORY_ENCLOSING_MARK

IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK

IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER

IntlChar::CHAR_CATEGORY_LETTER_NUMBER

IntlChar::CHAR_CATEGORY_OTHER_NUMBER

IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR

IntlChar::CHAR_CATEGORY_LINE_SEPARATOR

IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR

IntlChar::CHAR_CATEGORY_CONTROL_CHAR

IntlChar::CHAR_CATEGORY_FORMAT_CHAR

IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR

IntlChar::CHAR_CATEGORY_SURROGATE

IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION

IntlChar::CHAR_CATEGORY_START_PUNCTUATION

IntlChar::CHAR_CATEGORY_END_PUNCTUATION

IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION

IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION

IntlChar::CHAR_CATEGORY_MATH_SYMBOL

IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL

IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL

IntlChar::CHAR_CATEGORY_OTHER_SYMBOL

IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION

IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION

IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT

IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT

IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT

IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER

IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR

IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR

IntlChar::CHAR_DIRECTION_ARABIC_NUMBER

IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR

IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR

IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR

IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL

IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL

IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING

IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE

IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC

IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING

IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE

IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT

IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK

IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL

IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE

IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE

IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE

IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE

IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT

IntlChar::BLOCK_CODE_NO_BLOCK

IntlChar::BLOCK_CODE_BASIC_LATIN

IntlChar::BLOCK_CODE_LATIN_1_SUPPLEMENT

IntlChar::BLOCK_CODE_LATIN_EXTENDED_A

IntlChar::BLOCK_CODE_LATIN_EXTENDED_B

IntlChar::BLOCK_CODE_IPA_EXTENSIONS

IntlChar::BLOCK_CODE_SPACING_MODIFIER_LETTERS

IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS

IntlChar::BLOCK_CODE_GREEK

IntlChar::BLOCK_CODE_CYRILLIC

IntlChar::BLOCK_CODE_ARMENIAN

IntlChar::BLOCK_CODE_HEBREW

IntlChar::BLOCK_CODE_ARABIC

IntlChar::BLOCK_CODE_SYRIAC

IntlChar::BLOCK_CODE_THAANA

IntlChar::BLOCK_CODE_DEVANAGARI

IntlChar::BLOCK_CODE_BENGALI

IntlChar::BLOCK_CODE_GURMUKHI

IntlChar::BLOCK_CODE_GUJARATI

IntlChar::BLOCK_CODE_ORIYA

IntlChar::BLOCK_CODE_TAMIL

IntlChar::BLOCK_CODE_TELUGU

IntlChar::BLOCK_CODE_KANNADA

IntlChar::BLOCK_CODE_MALAYALAM

IntlChar::BLOCK_CODE_SINHALA

IntlChar::BLOCK_CODE_THAI

IntlChar::BLOCK_CODE_LAO

IntlChar::BLOCK_CODE_TIBETAN

IntlChar::BLOCK_CODE_MYANMAR

IntlChar::BLOCK_CODE_GEORGIAN

IntlChar::BLOCK_CODE_HANGUL_JAMO

IntlChar::BLOCK_CODE_ETHIOPIC

IntlChar::BLOCK_CODE_CHEROKEE

IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS

IntlChar::BLOCK_CODE_OGHAM

IntlChar::BLOCK_CODE_RUNIC

IntlChar::BLOCK_CODE_KHMER

IntlChar::BLOCK_CODE_MONGOLIAN

IntlChar::BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL

IntlChar::BLOCK_CODE_GREEK_EXTENDED

IntlChar::BLOCK_CODE_GENERAL_PUNCTUATION

IntlChar::BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS

IntlChar::BLOCK_CODE_CURRENCY_SYMBOLS

IntlChar::BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS

IntlChar::BLOCK_CODE_LETTERLIKE_SYMBOLS

IntlChar::BLOCK_CODE_NUMBER_FORMS

IntlChar::BLOCK_CODE_ARROWS

IntlChar::BLOCK_CODE_MATHEMATICAL_OPERATORS

IntlChar::BLOCK_CODE_MISCELLANEOUS_TECHNICAL

IntlChar::BLOCK_CODE_CONTROL_PICTURES

IntlChar::BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION

IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERICS

IntlChar::BLOCK_CODE_BOX_DRAWING

IntlChar::BLOCK_CODE_BLOCK_ELEMENTS

IntlChar::BLOCK_CODE_GEOMETRIC_SHAPES

IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS

IntlChar::BLOCK_CODE_DINGBATS

IntlChar::BLOCK_CODE_BRAILLE_PATTERNS

IntlChar::BLOCK_CODE_CJK_RADICALS_SUPPLEMENT

IntlChar::BLOCK_CODE_KANGXI_RADICALS

IntlChar::BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS

IntlChar::BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION

IntlChar::BLOCK_CODE_HIRAGANA

IntlChar::BLOCK_CODE_KATAKANA

IntlChar::BLOCK_CODE_BOPOMOFO

IntlChar::BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO

IntlChar::BLOCK_CODE_KANBUN

IntlChar::BLOCK_CODE_BOPOMOFO_EXTENDED

IntlChar::BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS

IntlChar::BLOCK_CODE_CJK_COMPATIBILITY

IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A

IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS

IntlChar::BLOCK_CODE_YI_SYLLABLES

IntlChar::BLOCK_CODE_YI_RADICALS

IntlChar::BLOCK_CODE_HANGUL_SYLLABLES

IntlChar::BLOCK_CODE_HIGH_SURROGATES

IntlChar::BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES

IntlChar::BLOCK_CODE_LOW_SURROGATES

IntlChar::BLOCK_CODE_PRIVATE_USE_AREA

IntlChar::BLOCK_CODE_PRIVATE_USE

IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS

IntlChar::BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS

IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A

IntlChar::BLOCK_CODE_COMBINING_HALF_MARKS

IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_FORMS

IntlChar::BLOCK_CODE_SMALL_FORM_VARIANTS

IntlChar::BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B

IntlChar::BLOCK_CODE_SPECIALS

IntlChar::BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS

IntlChar::BLOCK_CODE_OLD_ITALIC

IntlChar::BLOCK_CODE_GOTHIC

IntlChar::BLOCK_CODE_DESERET

IntlChar::BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS

IntlChar::BLOCK_CODE_MUSICAL_SYMBOLS

IntlChar::BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS

IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B

IntlChar::BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT

IntlChar::BLOCK_CODE_TAGS

IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENT

IntlChar::BLOCK_CODE_CYRILLIC_SUPPLEMENTARY

IntlChar::BLOCK_CODE_TAGALOG

IntlChar::BLOCK_CODE_HANUNOO

IntlChar::BLOCK_CODE_BUHID

IntlChar::BLOCK_CODE_TAGBANWA

IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A

IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_A

IntlChar::BLOCK_CODE_SUPPLEMENTAL_ARROWS_B

IntlChar::BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B

IntlChar::BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS

IntlChar::BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS

IntlChar::BLOCK_CODE_VARIATION_SELECTORS

IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A

IntlChar::BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B

IntlChar::BLOCK_CODE_LIMBU

IntlChar::BLOCK_CODE_TAI_LE

IntlChar::BLOCK_CODE_KHMER_SYMBOLS

IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS

IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS

IntlChar::BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS

IntlChar::BLOCK_CODE_LINEAR_B_SYLLABARY

IntlChar::BLOCK_CODE_LINEAR_B_IDEOGRAMS

IntlChar::BLOCK_CODE_AEGEAN_NUMBERS

IntlChar::BLOCK_CODE_UGARITIC

IntlChar::BLOCK_CODE_SHAVIAN

IntlChar::BLOCK_CODE_OSMANYA

IntlChar::BLOCK_CODE_CYPRIOT_SYLLABARY

IntlChar::BLOCK_CODE_TAI_XUAN_JING_SYMBOLS

IntlChar::BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT

IntlChar::BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION

IntlChar::BLOCK_CODE_ANCIENT_GREEK_NUMBERS

IntlChar::BLOCK_CODE_ARABIC_SUPPLEMENT

IntlChar::BLOCK_CODE_BUGINESE

IntlChar::BLOCK_CODE_CJK_STROKES

IntlChar::BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT

IntlChar::BLOCK_CODE_COPTIC

IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED

IntlChar::BLOCK_CODE_ETHIOPIC_SUPPLEMENT

IntlChar::BLOCK_CODE_GEORGIAN_SUPPLEMENT

IntlChar::BLOCK_CODE_GLAGOLITIC

IntlChar::BLOCK_CODE_KHAROSHTHI

IntlChar::BLOCK_CODE_MODIFIER_TONE_LETTERS

IntlChar::BLOCK_CODE_NEW_TAI_LUE

IntlChar::BLOCK_CODE_OLD_PERSIAN

IntlChar::BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT

IntlChar::BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION

IntlChar::BLOCK_CODE_SYLOTI_NAGRI

IntlChar::BLOCK_CODE_TIFINAGH

IntlChar::BLOCK_CODE_VERTICAL_FORMS

IntlChar::BLOCK_CODE_NKO

IntlChar::BLOCK_CODE_BALINESE

IntlChar::BLOCK_CODE_LATIN_EXTENDED_C

IntlChar::BLOCK_CODE_LATIN_EXTENDED_D

IntlChar::BLOCK_CODE_PHAGS_PA

IntlChar::BLOCK_CODE_PHOENICIAN

IntlChar::BLOCK_CODE_CUNEIFORM

IntlChar::BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION

IntlChar::BLOCK_CODE_COUNTING_ROD_NUMERALS

IntlChar::BLOCK_CODE_SUNDANESE

IntlChar::BLOCK_CODE_LEPCHA

IntlChar::BLOCK_CODE_OL_CHIKI

IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_A

IntlChar::BLOCK_CODE_VAI

IntlChar::BLOCK_CODE_CYRILLIC_EXTENDED_B

IntlChar::BLOCK_CODE_SAURASHTRA

IntlChar::BLOCK_CODE_KAYAH_LI

IntlChar::BLOCK_CODE_REJANG

IntlChar::BLOCK_CODE_CHAM

IntlChar::BLOCK_CODE_ANCIENT_SYMBOLS

IntlChar::BLOCK_CODE_PHAISTOS_DISC

IntlChar::BLOCK_CODE_LYCIAN

IntlChar::BLOCK_CODE_CARIAN

IntlChar::BLOCK_CODE_LYDIAN

IntlChar::BLOCK_CODE_MAHJONG_TILES

IntlChar::BLOCK_CODE_DOMINO_TILES

IntlChar::BLOCK_CODE_SAMARITAN

IntlChar::BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED

IntlChar::BLOCK_CODE_TAI_THAM

IntlChar::BLOCK_CODE_VEDIC_EXTENSIONS

IntlChar::BLOCK_CODE_LISU

IntlChar::BLOCK_CODE_BAMUM

IntlChar::BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS

IntlChar::BLOCK_CODE_DEVANAGARI_EXTENDED

IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_A

IntlChar::BLOCK_CODE_JAVANESE

IntlChar::BLOCK_CODE_MYANMAR_EXTENDED_A

IntlChar::BLOCK_CODE_TAI_VIET

IntlChar::BLOCK_CODE_MEETEI_MAYEK

IntlChar::BLOCK_CODE_HANGUL_JAMO_EXTENDED_B

IntlChar::BLOCK_CODE_IMPERIAL_ARAMAIC

IntlChar::BLOCK_CODE_OLD_SOUTH_ARABIAN

IntlChar::BLOCK_CODE_AVESTAN

IntlChar::BLOCK_CODE_INSCRIPTIONAL_PARTHIAN

IntlChar::BLOCK_CODE_INSCRIPTIONAL_PAHLAVI

IntlChar::BLOCK_CODE_OLD_TURKIC

IntlChar::BLOCK_CODE_RUMI_NUMERAL_SYMBOLS

IntlChar::BLOCK_CODE_KAITHI

IntlChar::BLOCK_CODE_EGYPTIAN_HIEROGLYPHS

IntlChar::BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT

IntlChar::BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT

IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C

IntlChar::BLOCK_CODE_MANDAIC

IntlChar::BLOCK_CODE_BATAK

IntlChar::BLOCK_CODE_ETHIOPIC_EXTENDED_A

IntlChar::BLOCK_CODE_BRAHMI

IntlChar::BLOCK_CODE_BAMUM_SUPPLEMENT

IntlChar::BLOCK_CODE_KANA_SUPPLEMENT

IntlChar::BLOCK_CODE_PLAYING_CARDS

IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS

IntlChar::BLOCK_CODE_EMOTICONS

IntlChar::BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS

IntlChar::BLOCK_CODE_ALCHEMICAL_SYMBOLS

IntlChar::BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D

IntlChar::BLOCK_CODE_ARABIC_EXTENDED_A

IntlChar::BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS

IntlChar::BLOCK_CODE_CHAKMA

IntlChar::BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS

IntlChar::BLOCK_CODE_MEROITIC_CURSIVE

IntlChar::BLOCK_CODE_MEROITIC_HIEROGLYPHS

IntlChar::BLOCK_CODE_MIAO

IntlChar::BLOCK_CODE_SHARADA

IntlChar::BLOCK_CODE_SORA_SOMPENG

IntlChar::BLOCK_CODE_SUNDANESE_SUPPLEMENT

IntlChar::BLOCK_CODE_TAKRI

IntlChar::BLOCK_CODE_COUNT

IntlChar::BLOCK_CODE_INVALID_CODE

IntlChar::BPT_NONE

IntlChar::BPT_OPEN

IntlChar::BPT_CLOSE

IntlChar::BPT_COUNT

IntlChar::EA_NEUTRAL

IntlChar::EA_AMBIGUOUS

IntlChar::EA_HALFWIDTH

IntlChar::EA_FULLWIDTH

IntlChar::EA_NARROW

IntlChar::EA_WIDE

IntlChar::EA_COUNT

IntlChar::UNICODE_CHAR_NAME

IntlChar::UNICODE_10_CHAR_NAME

IntlChar::EXTENDED_CHAR_NAME

IntlChar::CHAR_NAME_ALIAS

IntlChar::CHAR_NAME_CHOICE_COUNT

IntlChar::SHORT_PROPERTY_NAME

IntlChar::LONG_PROPERTY_NAME

IntlChar::PROPERTY_NAME_CHOICE_COUNT

IntlChar::DT_NONE

IntlChar::DT_CANONICAL

IntlChar::DT_COMPAT

IntlChar::DT_CIRCLE

IntlChar::DT_FINAL

IntlChar::DT_FONT

IntlChar::DT_FRACTION

IntlChar::DT_INITIAL

IntlChar::DT_ISOLATED

IntlChar::DT_MEDIAL

IntlChar::DT_NARROW

IntlChar::DT_NOBREAK

IntlChar::DT_SMALL

IntlChar::DT_SQUARE

IntlChar::DT_SUB

IntlChar::DT_SUPER

IntlChar::DT_VERTICAL

IntlChar::DT_WIDE

IntlChar::DT_COUNT

IntlChar::JT_NON_JOINING

IntlChar::JT_JOIN_CAUSING

IntlChar::JT_DUAL_JOINING

IntlChar::JT_LEFT_JOINING

IntlChar::JT_RIGHT_JOINING

IntlChar::JT_TRANSPARENT

IntlChar::JT_COUNT

IntlChar::JG_NO_JOINING_GROUP

IntlChar::JG_AIN

IntlChar::JG_ALAPH

IntlChar::JG_ALEF

IntlChar::JG_BEH

IntlChar::JG_BETH

IntlChar::JG_DAL

IntlChar::JG_DALATH_RISH

IntlChar::JG_E

IntlChar::JG_FEH

IntlChar::JG_FINAL_SEMKATH

IntlChar::JG_GAF

IntlChar::JG_GAMAL

IntlChar::JG_HAH

IntlChar::JG_TEH_MARBUTA_GOAL

IntlChar::JG_HAMZA_ON_HEH_GOAL

IntlChar::JG_HE

IntlChar::JG_HEH

IntlChar::JG_HEH_GOAL

IntlChar::JG_HETH

IntlChar::JG_KAF

IntlChar::JG_KAPH

IntlChar::JG_KNOTTED_HEH

IntlChar::JG_LAM

IntlChar::JG_LAMADH

IntlChar::JG_MEEM

IntlChar::JG_MIM

IntlChar::JG_NOON

IntlChar::JG_NUN

IntlChar::JG_PE

IntlChar::JG_QAF

IntlChar::JG_QAPH

IntlChar::JG_REH

IntlChar::JG_REVERSED_PE

IntlChar::JG_SAD

IntlChar::JG_SADHE

IntlChar::JG_SEEN

IntlChar::JG_SEMKATH

IntlChar::JG_SHIN

IntlChar::JG_SWASH_KAF

IntlChar::JG_SYRIAC_WAW

IntlChar::JG_TAH

IntlChar::JG_TAW

IntlChar::JG_TEH_MARBUTA

IntlChar::JG_TETH

IntlChar::JG_WAW

IntlChar::JG_YEH

IntlChar::JG_YEH_BARREE

IntlChar::JG_YEH_WITH_TAIL

IntlChar::JG_YUDH

IntlChar::JG_YUDH_HE

IntlChar::JG_ZAIN

IntlChar::JG_FE

IntlChar::JG_KHAPH

IntlChar::JG_ZHAIN

IntlChar::JG_BURUSHASKI_YEH_BARREE

IntlChar::JG_FARSI_YEH

IntlChar::JG_NYA

IntlChar::JG_ROHINGYA_YEH

IntlChar::JG_COUNT

IntlChar::GCB_OTHER

IntlChar::GCB_CONTROL

IntlChar::GCB_CR

IntlChar::GCB_EXTEND

IntlChar::GCB_L

IntlChar::GCB_LF

IntlChar::GCB_LV

IntlChar::GCB_LVT

IntlChar::GCB_T

IntlChar::GCB_V

IntlChar::GCB_SPACING_MARK

IntlChar::GCB_PREPEND

IntlChar::GCB_REGIONAL_INDICATOR

IntlChar::GCB_COUNT

IntlChar::WB_OTHER

IntlChar::WB_ALETTER

IntlChar::WB_FORMAT

IntlChar::WB_KATAKANA

IntlChar::WB_MIDLETTER

IntlChar::WB_MIDNUM

IntlChar::WB_NUMERIC

IntlChar::WB_EXTENDNUMLET

IntlChar::WB_CR

IntlChar::WB_EXTEND

IntlChar::WB_LF

IntlChar::WB_MIDNUMLET

IntlChar::WB_NEWLINE

IntlChar::WB_REGIONAL_INDICATOR

IntlChar::WB_HEBREW_LETTER

IntlChar::WB_SINGLE_QUOTE

IntlChar::WB_DOUBLE_QUOTE

IntlChar::WB_COUNT

IntlChar::SB_OTHER

IntlChar::SB_ATERM

IntlChar::SB_CLOSE

IntlChar::SB_FORMAT

IntlChar::SB_LOWER

IntlChar::SB_NUMERIC

IntlChar::SB_OLETTER

IntlChar::SB_SEP

IntlChar::SB_SP

IntlChar::SB_STERM

IntlChar::SB_UPPER

IntlChar::SB_CR

IntlChar::SB_EXTEND

IntlChar::SB_LF

IntlChar::SB_SCONTINUE

IntlChar::SB_COUNT

IntlChar::LB_UNKNOWN

IntlChar::LB_AMBIGUOUS

IntlChar::LB_ALPHABETIC

IntlChar::LB_BREAK_BOTH

IntlChar::LB_BREAK_AFTER

IntlChar::LB_BREAK_BEFORE

IntlChar::LB_MANDATORY_BREAK

IntlChar::LB_CONTINGENT_BREAK

IntlChar::LB_CLOSE_PUNCTUATION

IntlChar::LB_COMBINING_MARK

IntlChar::LB_CARRIAGE_RETURN

IntlChar::LB_EXCLAMATION

IntlChar::LB_GLUE

IntlChar::LB_HYPHEN

IntlChar::LB_IDEOGRAPHIC

IntlChar::LB_INSEPARABLE

IntlChar::LB_INSEPERABLE

IntlChar::LB_INFIX_NUMERIC

IntlChar::LB_LINE_FEED

IntlChar::LB_NONSTARTER

IntlChar::LB_NUMERIC

IntlChar::LB_OPEN_PUNCTUATION

IntlChar::LB_POSTFIX_NUMERIC

IntlChar::LB_PREFIX_NUMERIC

IntlChar::LB_QUOTATION

IntlChar::LB_COMPLEX_CONTEXT

IntlChar::LB_SURROGATE

IntlChar::LB_SPACE

IntlChar::LB_BREAK_SYMBOLS

IntlChar::LB_ZWSPACE

IntlChar::LB_NEXT_LINE

IntlChar::LB_WORD_JOINER

IntlChar::LB_H2

IntlChar::LB_H3

IntlChar::LB_JL

IntlChar::LB_JT

IntlChar::LB_JV

IntlChar::LB_CLOSE_PARENTHESIS

IntlChar::LB_CONDITIONAL_JAPANESE_STARTER

IntlChar::LB_HEBREW_LETTER

IntlChar::LB_REGIONAL_INDICATOR

IntlChar::LB_COUNT

IntlChar::NT_NONE

IntlChar::NT_DECIMAL

IntlChar::NT_DIGIT

IntlChar::NT_NUMERIC

IntlChar::NT_COUNT

IntlChar::HST_NOT_APPLICABLE

IntlChar::HST_LEADING_JAMO

IntlChar::HST_VOWEL_JAMO

IntlChar::HST_TRAILING_JAMO

IntlChar::HST_LV_SYLLABLE

IntlChar::HST_LVT_SYLLABLE

IntlChar::HST_COUNT

IntlChar::FOLD_CASE_DEFAULT

IntlChar::FOLD_CASE_EXCLUDE_SPECIAL_I

Changelog

Version Description
7.0.6 The IntlChar::NO_NUMERIC_VALUE constant was added.


IntlChar::charAge

(PHP 7)

IntlChar::charAgeGet the "age" of the code point

Description

public static IntlChar::charAge ( mixed $codepoint ) : array

Gets the "age" of the code point.

The "age" is the Unicode version when the code point was first designated (as a non-character or for Private Use) or assigned a character. This can be useful to avoid emitting code points to receiving processes that do not accept newer characters.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

The Unicode version number, as an array. For example, version 1.3.31.2 would be represented as [1, 3, 31, 2].

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charage("\u{2603}"));
var_dump(IntlChar::charage("\u{1F576}"));
?>

The above example will output:

   array(4) {
     [0]=>
     int(1)
     [1]=>
     int(1)
     [2]=>
     int(0)
     [3]=>
     int(0)
   }
   array(4) {
     [0]=>
     int(7)
     [1]=>
     int(0)
     [2]=>
     int(0)
     [3]=>
     int(0)
   }
   

See Also



IntlChar::charDigitValue

(PHP 7)

IntlChar::charDigitValueGet the decimal digit value of a decimal digit character

Description

public static IntlChar::charDigitValue ( mixed $codepoint ) : int

Returns the decimal digit value of a decimal digit character.

Such characters have the general category "Nd" (decimal digit numbers) and a Numeric_Type of Decimal.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

The decimal digit value of codepoint, or -1 if it is not a decimal digit character.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charDigitValue("1"));
var_dump(IntlChar::charDigitValue("\u{0662}"));
var_dump(IntlChar::charDigitValue("\u{0E53}"));
?>

The above example will output:

   int(1)
   int(2)
   int(3)
   

See Also



IntlChar::charDirection

(PHP 7)

IntlChar::charDirectionGet bidirectional category value for a code point

Description

public static IntlChar::charDirection ( mixed $codepoint ) : int

Returns the bidirectional category value for the code point, which is used in the » Unicode bidirectional algorithm (UAX #9).

Note:

Some unassigned code points have bidi values of R or AL because they are in blocks that are reserved for Right-To-Left scripts.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

The bidirectional category value; one of the following constants:

  • IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT
  • IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT
  • IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER
  • IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR
  • IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR
  • IntlChar::CHAR_DIRECTION_ARABIC_NUMBER
  • IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR
  • IntlChar::CHAR_DIRECTION_BLOCK_SEPARATOR
  • IntlChar::CHAR_DIRECTION_SEGMENT_SEPARATOR
  • IntlChar::CHAR_DIRECTION_WHITE_SPACE_NEUTRAL
  • IntlChar::CHAR_DIRECTION_OTHER_NEUTRAL
  • IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING
  • IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE
  • IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC
  • IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING
  • IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE
  • IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT
  • IntlChar::CHAR_DIRECTION_DIR_NON_SPACING_MARK
  • IntlChar::CHAR_DIRECTION_BOUNDARY_NEUTRAL
  • IntlChar::CHAR_DIRECTION_FIRST_STRONG_ISOLATE
  • IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE
  • IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE
  • IntlChar::CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE
  • IntlChar::CHAR_DIRECTION_CHAR_DIRECTION_COUNT

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charDirection("A") === IntlChar::CHAR_DIRECTION_LEFT_TO_RIGHT);
var_dump(IntlChar::charDirection("\u{05E9}") === IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
var_dump(IntlChar::charDirection("+") === IntlChar::CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR);
var_dump(IntlChar::charDirection(".") === IntlChar::CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   bool(true)
   


IntlChar::charFromName

(PHP 7)

IntlChar::charFromNameFind Unicode character by name and return its code point value

Description

public static IntlChar::charFromName ( string $characterName [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : int

Finds a Unicode character by its name and returns its code point value.

The name is matched exactly and completely. If the name does not correspond to a code point, NULL is returned.

A Unicode 1.0 name is matched only if it differs from the modern name. Unicode names are all uppercase. Extended names are lowercase followed by an uppercase hexadecimal number, and within angle brackets.

Parameters

characterName

Full name of the Unicode character.

nameChoice

Which set of names to use for the lookup. Can be any of these constants:

  • IntlChar::UNICODE_CHAR_NAME (default)
  • IntlChar::UNICODE_10_CHAR_NAME
  • IntlChar::EXTENDED_CHAR_NAME
  • IntlChar::CHAR_NAME_ALIAS
  • IntlChar::CHAR_NAME_CHOICE_COUNT

Return Values

The Unicode value of the code point with the given name (as an integer), or NULL if there is no such code point.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charFromName("LATIN CAPITAL LETTER A"));
var_dump(IntlChar::charFromName("SNOWMAN"));
var_dump(IntlChar::charFromName("RECYCLING SYMBOL FOR TYPE-1 PLASTICS"));
var_dump(IntlChar::charFromName("A RANDOM STRING WHICH DOESN'T CORRESPOND TO ANY UNICODE CHARACTER"));
?>

The above example will output:

   int(65)
   int(9731)
   int(9843)
   bool(false)
   

See Also



IntlChar::charMirror

(PHP 7)

IntlChar::charMirrorGet the "mirror-image" character for a code point

Description

public static IntlChar::charMirror ( mixed $codepoint ) : mixed

Maps the specified character to a "mirror-image" character.

For characters with the Bidi_Mirrored property, implementations sometimes need a "poor man's" mapping to another Unicode character (code point) such that the default glyph may serve as the mirror-image of the default glyph of the specified character. This is useful for text conversion to and from codepages with visual order, and for displays without glyph selection capabilities.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns another Unicode code point that may serve as a mirror-image substitute, or codepoint itself if there is no such mapping or codepoint does not have the Bidi_Mirrored property.

The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charMirror("A"));
var_dump(IntlChar::charMirror("<"));
var_dump(IntlChar::charMirror("("));
?>

The above example will output:

   string(1) "A"
   string(1) ">"
   string(2) ")"
   

See Also

  • IntlChar::isMirrored() - Check if code point has the Bidi_Mirrored property
  • IntlChar::PROPERTY_BIDI_MIRRORED



IntlChar::charName

(PHP 7)

IntlChar::charNameRetrieve the name of a Unicode character

Description

public static IntlChar::charName ( mixed $codepoint [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : string

Retrieves the name of a Unicode character.

Depending on nameChoice, the resulting character name is the "modern" name or the name that was defined in Unicode version 1.0. The name contains only "invariant" characters like A-Z, 0-9, space, and '-'. Unicode 1.0 names are only retrieved if they are different from the modern names and if ICU contains the data for them.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

nameChoice

Which set of names to use for the lookup. Can be any of these constants:

  • IntlChar::UNICODE_CHAR_NAME (default)
  • IntlChar::UNICODE_10_CHAR_NAME
  • IntlChar::EXTENDED_CHAR_NAME
  • IntlChar::CHAR_NAME_ALIAS
  • IntlChar::CHAR_NAME_CHOICE_COUNT

Return Values

The corresponding name, or an empty string if there is no name for this character, or NULL if there is no such code point.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charName("."));
var_dump(IntlChar::charName("."IntlChar::UNICODE_CHAR_NAME));
var_dump(IntlChar::charName("\u{2603}"));
var_dump(IntlChar::charName("\u{0000}"));
?>

The above example will output:

   string(9) "FULL STOP"
   string(9) "FULL STOP"
   string(7) "SNOWMAN"
   string(0) ""
   

See Also



IntlChar::charType

(PHP 7)

IntlChar::charTypeGet the general category value for a code point

Description

public static IntlChar::charType ( mixed $codepoint ) : int

Returns the general category value for the code point.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the general category type, which may be one of the following constants:

  • IntlChar::CHAR_CATEGORY_UNASSIGNED
  • IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES
  • IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER
  • IntlChar::CHAR_CATEGORY_LOWERCASE_LETTER
  • IntlChar::CHAR_CATEGORY_TITLECASE_LETTER
  • IntlChar::CHAR_CATEGORY_MODIFIER_LETTER
  • IntlChar::CHAR_CATEGORY_OTHER_LETTER
  • IntlChar::CHAR_CATEGORY_NON_SPACING_MARK
  • IntlChar::CHAR_CATEGORY_ENCLOSING_MARK
  • IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK
  • IntlChar::CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER
  • IntlChar::CHAR_CATEGORY_LETTER_NUMBER
  • IntlChar::CHAR_CATEGORY_OTHER_NUMBER
  • IntlChar::CHAR_CATEGORY_SPACE_SEPARATOR
  • IntlChar::CHAR_CATEGORY_LINE_SEPARATOR
  • IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR
  • IntlChar::CHAR_CATEGORY_CONTROL_CHAR
  • IntlChar::CHAR_CATEGORY_FORMAT_CHAR
  • IntlChar::CHAR_CATEGORY_PRIVATE_USE_CHAR
  • IntlChar::CHAR_CATEGORY_SURROGATE
  • IntlChar::CHAR_CATEGORY_DASH_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_START_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_END_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_CONNECTOR_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_MATH_SYMBOL
  • IntlChar::CHAR_CATEGORY_CURRENCY_SYMBOL
  • IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL
  • IntlChar::CHAR_CATEGORY_OTHER_SYMBOL
  • IntlChar::CHAR_CATEGORY_INITIAL_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_FINAL_PUNCTUATION
  • IntlChar::CHAR_CATEGORY_CHAR_CATEGORY_COUNT

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::charType("A") === IntlChar::CHAR_CATEGORY_UPPERCASE_LETTER);
var_dump(IntlChar::charType(".") === IntlChar::CHAR_CATEGORY_OTHER_PUNCTUATION);
var_dump(IntlChar::charType("\t") === IntlChar::CHAR_CATEGORY_CONTROL_CHAR);
var_dump(IntlChar::charType("\u{2603}") === IntlChar::CHAR_CATEGORY_OTHER_SYMBOL);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   bool(true)
   


IntlChar::chr

(PHP 7)

IntlChar::chrReturn Unicode character by code point value

Description

public static IntlChar::chr ( mixed $codepoint ) : string

Returns a string containing the character specified by the Unicode code point value.

This function compliments IntlChar::ord().

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

A string containing the single character specified by the Unicode code point value.

Examples

Example #1 Testing different code points

<?php
$values 
= ["A"631239731];
foreach (
$values as $value) {
    
var_dump(IntlChar::chr($value));
}
?>

The above example will output:

   string(1) "A"
   string(1) "?"
   string(1) "{"
   string(3) "☃"
   

See Also

  • IntlChar::ord() - Return Unicode code point value of character
  • chr() - Generate a single-byte string from a number



IntlChar::digit

(PHP 7)

IntlChar::digitGet the decimal digit value of a code point for a given radix

Description

public static IntlChar::digit ( string $codepoint [, int $radix = 10 ] ) : int

Returns the decimal digit value of the code point in the specified radix.

If the radix is not in the range 2<=radix<=36 or if the value of codepoint is not a valid digit in the specified radix, FALSE is returned. A character is a valid digit if at least one of the following is true:

  • The character has a decimal digit value. Such characters have the general category "Nd" (decimal digit numbers) and a Numeric_Type of Decimal. In this case the value is the character's decimal digit value.
  • The character is one of the uppercase Latin letters 'A' through 'Z'. In this case the value is c-'A'+10.
  • The character is one of the lowercase Latin letters 'a' through 'z'. In this case the value is ch-'a'+10.
  • Latin letters from both the ASCII range (0061..007A, 0041..005A) as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A) are recognized.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

radix

The radix (defaults to 10).

Return Values

Returns the numeric value represented by the character in the specified radix, or FALSE if there is no value or if the value exceeds the radix.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::digit("0"));
var_dump(IntlChar::digit("3"));
var_dump(IntlChar::digit("A"));
var_dump(IntlChar::digit("A"16));
?>

The above example will output:

   int(0)
   int(3)
   bool(false)
   int(10)
   

See Also



IntlChar::enumCharNames

(PHP 7)

IntlChar::enumCharNamesEnumerate all assigned Unicode characters within a range

Description

public static IntlChar::enumCharNames ( mixed $start , mixed $limit , callable $callback [, int $nameChoice = IntlChar::UNICODE_CHAR_NAME ] ) : void

Enumerate all assigned Unicode characters between the start and limit code points (start inclusive, limit exclusive) and call a function for each, passing the code point value and the character name.

For Unicode 1.0 names, only those are enumerated that differ from the modern names.

Parameters

start

The first code point in the enumeration range.

limit

One more than the last code point in the enumeration range (the first one after the range).

callback

The function that is to be called for each character name. The following three arguments will be passed into it:

  • integer $codepoint - The numeric code point value
  • integer $nameChoice - The same value as the nameChoice parameter below
  • string $name - The name of the character

nameChoice

Selector for which kind of names to enumerate. Can be any of these constants:

  • IntlChar::UNICODE_CHAR_NAME (default)
  • IntlChar::UNICODE_10_CHAR_NAME
  • IntlChar::EXTENDED_CHAR_NAME
  • IntlChar::CHAR_NAME_ALIAS
  • IntlChar::CHAR_NAME_CHOICE_COUNT

Return Values

No value is returned.

Examples

Example #1 Enumerating over a sample range of code points

<?php
IntlChar
::enumCharNames(0x26000x2610, function($codepoint$nameChoice$name) {
    
printf("U+%04x %s\n"$codepoint$name);
});
?>

The above example will output:

   U+2600 BLACK SUN WITH RAYS
   U+2601 CLOUD
   U+2602 UMBRELLA
   U+2603 SNOWMAN
   U+2604 COMET
   U+2605 BLACK STAR
   U+2606 WHITE STAR
   U+2607 LIGHTNING
   U+2608 THUNDERSTORM
   U+2609 SUN
   U+260a ASCENDING NODE
   U+260b DESCENDING NODE
   U+260c CONJUNCTION
   U+260d OPPOSITION
   U+260e BLACK TELEPHONE
   U+260f WHITE TELEPHONE
   

See Also



IntlChar::enumCharTypes

(PHP 7)

IntlChar::enumCharTypesEnumerate all code points with their Unicode general categories

Description

public static IntlChar::enumCharTypes ( callable $callback ) : void

Enumerates efficiently all code points with their Unicode general categories. This is useful for building data structures, for enumerating all assigned code points, etc.

For each contiguous range of code points with a given general category ("character type"), the callback function is called. Adjacent ranges have different types. The Unicode Standard guarantees that the numeric value of the type is 0..31.

Parameters

callback

The function that is to be called for each contiguous range of code points with the same general category. The following three arguments will be passed into it:

  • integer $start - The starting code point of the range
  • integer $end - The ending code point of the range
  • integer $name - The category type (one of the IntlChar::CHAR_CATEGORY_* constants)

Return Values

No value is returned.

Examples

Example #1 Enumerating over a sample range of code points

<?php
IntlChar
::enumCharTypes(function($start$end$type) {
    
printf("U+%04x through U+%04x are in category %d\n"$start$end$type);
});
?>

The above example will output:

   U+0000 through U+0020 are in category 15
   U+0020 through U+0021 are in category 12
   U+0021 through U+0024 are in category 23
   U+0024 through U+0025 are in category 25
   U+0025 through U+0028 are in category 23
   U+0028 through U+0029 are in category 20
   U+0029 through U+002a are in category 21
   U+002a through U+002b are in category 23
   U+002b through U+002c are in category 24
   U+002c through U+002d are in category 23
   U+002d through U+002e are in category 19
   U+002e through U+0030 are in category 23
   U+0030 through U+003a are in category 9
   ...
   


IntlChar::foldCase

(PHP 7)

IntlChar::foldCasePerform case folding on a code point

Description

public static IntlChar::foldCase ( mixed $codepoint [, int $options = IntlChar::FOLD_CASE_DEFAULT ] ) : mixed

The given character is mapped to its case folding equivalent; if the character has no case folding equivalent, the character itself is returned.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

options

Either IntlChar::FOLD_CASE_DEFAULT (default) or IntlChar::FOLD_CASE_EXCLUDE_SPECIAL_I.

Return Values

Returns the Simple_Case_Folding of the code point, if any; otherwise the code point itself.



IntlChar::forDigit

(PHP 7)

IntlChar::forDigitGet character representation for a given digit and radix

Description

public static IntlChar::forDigit ( int $digit [, int $radix = 10 ] ) : int

Determines the character representation for a specific digit in the specified radix.

If the value of radix is not a valid radix, or the value of digit is not a valid digit in the specified radix, the null character (U+0000) is returned.

The radix argument is valid if it is greater than or equal to 2 and less than or equal to 36. The digit argument is valid if 0 <= digit < radix.

If the digit is less than 10, then '0' + digit is returned. Otherwise, the value 'a' + digit - 10 is returned.

Parameters

digit

The number to convert to a character.

radix

The radix (defaults to 10).

Return Values

The character representation (as a string) of the specified digit in the specified radix.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::forDigit(0));
var_dump(IntlChar::forDigit(3));
var_dump(IntlChar::forDigit(310));
var_dump(IntlChar::forDigit(10));
var_dump(IntlChar::forDigit(1016));
?>

The above example will output:

   int(48)
   int(51)
   int(51)
   int(0)
   int(97)
   

See Also



IntlChar::getBidiPairedBracket

(PHP 7)

IntlChar::getBidiPairedBracketGet the paired bracket character for a code point

Description

public static IntlChar::getBidiPairedBracket ( mixed $codepoint ) : mixed

Maps the specified character to its paired bracket character.

For Bidi_Paired_Bracket_Type!=None, this is the same as IntlChar::charMirror(). Otherwise codepoint itself is returned.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the paired bracket code point, or codepoint itself if there is no such mapping.

The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::getBidiPairedBracket(91));
var_dump(IntlChar::getBidiPairedBracket('['));
?>

The above example will output:

   int(93)
   string(1) "]"
   

See Also

  • IntlChar::charMirror() - Get the "mirror-image" character for a code point
  • IntlChar::PROPERTY_BIDI_PAIRED_BRACKET
  • IntlChar::PROPERTY_BIDI_PAIRED_BRACKET_TYPE



IntlChar::getBlockCode

(PHP 7)

IntlChar::getBlockCodeGet the Unicode allocation block containing a code point

Description

public static IntlChar::getBlockCode ( mixed $codepoint ) : int

Returns the Unicode allocation block that contains the character.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the block value for codepoint. See the IntlChar::BLOCK_CODE_* constants for possible return values.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::getBlockCode("A") === IntlChar::BLOCK_CODE_BASIC_LATIN);
var_dump(IntlChar::getBlockCode("Φ") === IntlChar::BLOCK_CODE_GREEK);
var_dump(IntlChar::getBlockCode("\u{2603}") === IntlChar::BLOCK_CODE_MISCELLANEOUS_SYMBOLS);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   


IntlChar::getCombiningClass

(PHP 7)

IntlChar::getCombiningClassGet the combining class of a code point

Description

public static IntlChar::getCombiningClass ( mixed $codepoint ) : int

Returns the combining class of the code point.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the combining class of the character.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::getCombiningClass("A"));
var_dump(IntlChar::getCombiningClass("\u{0334}"));
var_dump(IntlChar::getCombiningClass("\u{0358}"));
?>

The above example will output:

   int(0)
   int(1)
   int(232)
   


IntlChar::getFC_NFKC_Closure

(PHP 7)

IntlChar::getFC_NFKC_ClosureGet the FC_NFKC_Closure property for a code point

Description

public static IntlChar::getFC_NFKC_Closure ( mixed $codepoint ) : string

Gets the FC_NFKC_Closure property string for a character.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the FC_NFKC_Closure property string for the codepoint, or an empty string if there is none.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::getFC_NFKC_Closure("\u{2121}"));
var_dump(IntlChar::getFC_NFKC_Closure("\u{1D2D}"));
?>

The above example will output:

   string(3) "tel"
   string(2) "æ"
   


IntlChar::getIntPropertyMaxValue

(PHP 7)

IntlChar::getIntPropertyMaxValueGet the max value for a Unicode property

Description

public static IntlChar::getIntPropertyMaxValue ( int $property ) : int

Gets the maximum value for an enumerated/integer/binary Unicode property.

Parameters

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

Return Values

The maximum value returned by IntlChar::getIntPropertyValue() for a Unicode property. <=0 if the property selector is out of range.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_SCRIPT));
var_dump(IntlChar::getIntPropertyMaxValue(IntlChar::PROPERTY_IDEOGRAPHIC));
var_dump(IntlChar::getIntPropertyMaxValue(999999999)); // Some made-up value
?>

The above example will output:

   int(22)
   int(166)
   int(1)
   int(-1)
   

See Also



IntlChar::getIntPropertyMinValue

(PHP 7)

IntlChar::getIntPropertyMinValueGet the min value for a Unicode property

Description

public static IntlChar::getIntPropertyMinValue ( int $property ) : int

Gets the minimum value for an enumerated/integer/binary Unicode property.

Parameters

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

Return Values

The minimum value returned by IntlChar::getIntPropertyValue() for a Unicode property. 0 if the property selector is out of range.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_SCRIPT));
var_dump(IntlChar::getIntPropertyMinValue(IntlChar::PROPERTY_IDEOGRAPHIC));
var_dump(IntlChar::getIntPropertyMinValue(999999999)); // Some made-up value
?>

The above example will output:

   int(0)
   int(0)
   int(0)
   int(0)
   

See Also



IntlChar::getIntPropertyValue

(PHP 7)

IntlChar::getIntPropertyValueGet the value for a Unicode property for a code point

Description

public static IntlChar::getIntPropertyValue ( mixed $codepoint , int $property ) : int

Gets the property value for an enumerated or integer Unicode property for a code point. Also returns binary and mask property values.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

Return Values

Returns the numeric value that is directly the property value or, for enumerated properties, corresponds to the numeric value of the enumerated constant of the respective property value enumeration type.

Returns 0 or 1 (for FALSE/TRUE) for binary Unicode properties.

Returns a bit-mask for mask properties.

Returns 0 if property is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getIntPropertyValue("A"IntlChar::PROPERTY_ALPHABETIC) === 1);
var_dump(IntlChar::getIntPropertyValue("["IntlChar::PROPERTY_BIDI_MIRRORED) === 1);
var_dump(IntlChar::getIntPropertyValue("Φ"IntlChar::PROPERTY_BLOCK) === IntlChar::BLOCK_CODE_GREEK);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   

See Also



IntlChar::getNumericValue

(PHP 7)

IntlChar::getNumericValueGet the numeric value for a Unicode code point

Description

public static IntlChar::getNumericValue ( mixed $codepoint ) : float

Gets the numeric value for a Unicode code point as defined in the Unicode Character Database.

For characters without any numeric values in the Unicode Character Database, this function will return IntlChar::NO_NUMERIC_VALUE.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Numeric value of codepoint, or IntlChar::NO_NUMERIC_VALUE if none is defined. This constant was added in PHP 7.0.6, prior to this version the literal value (float)-123456789 may be used instead.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::getNumericValue("4"));
var_dump(IntlChar::getNumericValue("x"));
var_dump(IntlChar::getNumericValue("\u{216C}"));
?>

The above example will output:

   float(4)
   float(-123456789)
   float(50)
   


IntlChar::getPropertyEnum

(PHP 7)

IntlChar::getPropertyEnumGet the property constant value for a given property name

Description

public static IntlChar::getPropertyEnum ( string $alias ) : int

Returns the property constant value for a given property name, as specified in the Unicode database file PropertyAliases.txt. Short, long, and any other variants are recognized.

In addition, this function maps the synthetic names "gcm" / "General_Category_Mask" to the property IntlChar::PROPERTY_GENERAL_CATEGORY_MASK. These names are not in PropertyAliases.txt.

This function compliments IntlChar::getPropertyName().

Parameters

alias

The property name to be matched. The name is compared using "loose matching" as described in PropertyAliases.txt.

Return Values

Returns an IntlChar::PROPERTY_ constant value, or IntlChar::PROPERTY_INVALID_CODE if the given name does not match any property.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getPropertyEnum('Bidi_Class') === IntlChar::PROPERTY_BIDI_CLASS);
var_dump(IntlChar::getPropertyEnum('script') === IntlChar::PROPERTY_SCRIPT);
var_dump(IntlChar::getPropertyEnum('IDEOGRAPHIC') === IntlChar::PROPERTY_IDEOGRAPHIC);
var_dump(IntlChar::getPropertyEnum('Some made-up string') === IntlChar::PROPERTY_INVALID_CODE);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   bool(true)
   

See Also



IntlChar::getPropertyName

(PHP 7)

IntlChar::getPropertyNameGet the Unicode name for a property

Description

public static IntlChar::getPropertyName ( int $property [, int $nameChoice = IntlChar::LONG_PROPERTY_NAME ] ) : string

Returns the Unicode name for a given property, as given in the Unicode database file PropertyAliases.txt.

In addition, this function maps the property IntlChar::PROPERTY_GENERAL_CATEGORY_MASK to the synthetic names "gcm" / "General_Category_Mask". These names are not in PropertyAliases.txt.

This function compliments IntlChar::getPropertyEnum().

Parameters

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

IntlChar::PROPERTY_INVALID_CODE should not be used. Also, if property is out of range, FALSE is returned.

nameChoice

Selector for which name to get. If out of range, FALSE is returned.

All properties have a long name. Most have a short name, but some do not. Unicode allows for additional names; if present these will be returned by adding 1, 2, etc. to IntlChar::LONG_PROPERTY_NAME.

Return Values

Returns the name, or FALSE if either the property or the nameChoice is out of range.

If a given nameChoice returns FALSE, then all larger values of nameChoice will return FALSE, with one exception: if FALSE is returned for IntlChar::SHORT_PROPERTY_NAME, then IntlChar::LONG_PROPERTY_NAME (and higher) may still return a non-FALSE value.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASS));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASSIntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASSIntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyName(IntlChar::PROPERTY_BIDI_CLASSIntlChar::LONG_PROPERTY_NAME 1));
?>

The above example will output:

   string(10) "Bidi_Class"
   string(2) "bc"
   string(10) "Bidi_Class"
   bool(false)
   

See Also



IntlChar::getPropertyValueEnum

(PHP 7)

IntlChar::getPropertyValueEnumGet the property value for a given value name

Description

public static IntlChar::getPropertyValueEnum ( int $property , string $name ) : int

Returns the property value integer for a given value name, as specified in the Unicode database file PropertyValueAliases.txt. Short, long, and any other variants are recognized.

Note:

Some of the names in PropertyValueAliases.txt will only be recognized with IntlChar::PROPERTY_GENERAL_CATEGORY_MASK, not IntlChar::PROPERTY_GENERAL_CATEGORY. These include:

  • "C" / "Other"
  • "L" / "Letter"
  • "LC" / "Cased_Letter"
  • "M" / "Mark"
  • "N" / "Number"
  • "P" / "Punctuation"
  • "S" / "Symbol"
  • "Z" / "Separator"

Parameters

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

If out of range, or this method doesn't work with the given value, IntlChar::PROPERTY_INVALID_CODE is returned.

name

The value name to be matched. The name is compared using "loose matching" as described in PropertyValueAliases.txt.

Return Values

Returns the corresponding value integer, or IntlChar::PROPERTY_INVALID_CODE if the given name does not match any value of the given property, or if the property is invalid.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BLOCK'greek') === IntlChar::BLOCK_CODE_GREEK);
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS'RIGHT_TO_LEFT') === IntlChar::CHAR_DIRECTION_RIGHT_TO_LEFT);
var_dump(IntlChar::getPropertyValueEnum(IntlChar::PROPERTY_BIDI_CLASS'some made-up string') === IntlChar::PROPERTY_INVALID_CODE);
var_dump(IntlChar::getPropertyValueEnum(123456789'RIGHT_TO_LEFT') === IntlChar::PROPERTY_INVALID_CODE);
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   bool(true)
   


IntlChar::getPropertyValueName

(PHP 7)

IntlChar::getPropertyValueNameGet the Unicode name for a property value

Description

public static IntlChar::getPropertyValueName ( int $property , int $value [, int $nameChoice = IntlChar::LONG_PROPERTY_NAME ] ) : string

Returns the Unicode name for a given property value, as given in the Unicode database file PropertyValueAliases.txt.

Note:

Some of the names in PropertyValueAliases.txt can only be retrieved using IntlChar::PROPERTY_GENERAL_CATEGORY_MASK, not IntlChar::PROPERTY_GENERAL_CATEGORY. These include:

  • "C" / "Other"
  • "L" / "Letter"
  • "LC" / "Cased_Letter"
  • "M" / "Mark"
  • "N" / "Number"
  • "P" / "Punctuation"
  • "S" / "Symbol"
  • "Z" / "Separator"

Parameters

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

If out of range, or this method doesn't work with the given value, FALSE is returned.

value

Selector for a value for the given property. If out of range, FALSE is returned.

In general, valid values range from 0 up to some maximum. There are a couple exceptions:

  • IntlChar::PROPERTY_BLOCK values begin at the non-zero value IntlChar::BLOCK_CODE_BASIC_LATIN
  • IntlChar::PROPERTY_CANONICAL_COMBINING_CLASS values are not contiguous and range from 0..240.

nameChoice

Selector for which name to get. If out of range, FALSE is returned.

All values have a long name. Most have a short name, but some do not. Unicode allows for additional names; if present these will be returned by adding 1, 2, etc. to IntlChar::LONG_PROPERTY_NAME.

Return Values

Returns the name, or FALSE if either the property or the nameChoice is out of range.

If a given nameChoice returns FALSE, then all larger values of nameChoice will return FALSE, with one exception: if FALSE is returned for IntlChar::SHORT_PROPERTY_NAME, then IntlChar::LONG_PROPERTY_NAME (and higher) may still return a non-FALSE value.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCKIntlChar::BLOCK_CODE_GREEK));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCKIntlChar::BLOCK_CODE_GREEKIntlChar::SHORT_PROPERTY_NAME));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCKIntlChar::BLOCK_CODE_GREEKIntlChar::LONG_PROPERTY_NAME));
var_dump(IntlChar::getPropertyValueName(IntlChar::PROPERTY_BLOCKIntlChar::BLOCK_CODE_GREEKIntlChar::LONG_PROPERTY_NAME 1));
?>

The above example will output:

   string(16) "Greek_And_Coptic"
   string(5) "Greek"
   string(16) "Greek_And_Coptic"
   bool(false)
   


IntlChar::getUnicodeVersion

(PHP 7)

IntlChar::getUnicodeVersionGet the Unicode version

Description

public static IntlChar::getUnicodeVersion ( void ) : array

Gets the Unicode version information.

The version array is filled in with the version information for the Unicode standard that is currently used by ICU. For example, Unicode version 3.1.1 is represented as an array with the values [3, 1, 1, 0].

Parameters

This function has no parameters.

Return Values

An array containing the Unicode version number.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::getUnicodeVersion());
?>

The above example will output:

   array(4) {
     [0]=>
     int(7)
     [1]=>
     int(0)
     [2]=>
     int(0)
     [3]=>
     int(0)
   }
   

See Also



IntlChar::hasBinaryProperty

(PHP 7)

IntlChar::hasBinaryPropertyCheck a binary Unicode property for a code point

Description

public static IntlChar::hasBinaryProperty ( mixed $codepoint , int $property ) : bool

Checks a binary Unicode property for a code point.

Unicode, especially in version 3.2, defines many more properties than the original set in UnicodeData.txt.

The properties APIs are intended to reflect Unicode properties as defined in the Unicode Character Database (UCD) and Unicode Technical Reports (UTR). For details about the properties see » http://www.unicode.org/ucd/. For names of Unicode properties see the UCD file PropertyAliases.txt.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

property

The Unicode property to lookup (see the IntlChar::PROPERTY_* constants).

Return Values

Returns TRUE or FALSE according to the binary Unicode property value for codepoint. Also FALSE if property is out of bounds or if the Unicode version does not have data for the property at all, or not for this code point.

Examples

Example #1 Testing different properties

<?php
var_dump
(IntlChar::hasBinaryProperty("A"IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty("A"IntlChar::PROPERTY_CASE_SENSITIVE));
var_dump(IntlChar::hasBinaryProperty("A"IntlChar::PROPERTY_BIDI_MIRRORED));
var_dump(IntlChar::hasBinaryProperty("["IntlChar::PROPERTY_ALPHABETIC));
var_dump(IntlChar::hasBinaryProperty("["IntlChar::PROPERTY_CASE_SENSITIVE));
var_dump(IntlChar::hasBinaryProperty("["IntlChar::PROPERTY_BIDI_MIRRORED));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   bool(false)
   bool(false)
   bool(true)
   

See Also



IntlChar::isalnum

(PHP 7)

IntlChar::isalnumCheck if code point is an alphanumeric character

Description

public static IntlChar::isalnum ( mixed $codepoint ) : bool

Determines whether the specified code point is an alphanumeric character (letter or digit). TRUE for characters with general categories "L" (letters) and "Nd" (decimal digit numbers).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is an alphanumeric character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isalnum("A"));
var_dump(IntlChar::isalnum("1"));
var_dump(IntlChar::isalnum("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   

See Also



IntlChar::isalpha

(PHP 7)

IntlChar::isalphaCheck if code point is a letter character

Description

public static IntlChar::isalpha ( mixed $codepoint ) : bool

Determines whether the specified code point is a letter character. TRUE for general categories "L" (letters).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a letter character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isalpha("A"));
var_dump(IntlChar::isalpha("1"));
var_dump(IntlChar::isalpha("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isbase

(PHP 7)

IntlChar::isbaseCheck if code point is a base character

Description

public static IntlChar::isbase ( mixed $codepoint ) : bool

Determines whether the specified code point is a base character. TRUE for general categories "L" (letters), "N" (numbers), "Mc" (spacing combining marks), and "Me" (enclosing marks).

Note:

This is different from the Unicode definition in chapter 3.5, conformance clause D13, which defines base characters to be all characters (not Cn) that do not graphically combine with preceding characters (M) and that are neither control (Cc) or format (Cf) characters.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a base character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isbase("A"));
var_dump(IntlChar::isbase("1"));
var_dump(IntlChar::isbase("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   

See Also



IntlChar::isblank

(PHP 7)

IntlChar::isblankCheck if code point is a "blank" or "horizontal space" character

Description

public static IntlChar::isblank ( mixed $codepoint ) : bool

Determines whether the specified code point is a "blank" or "horizontal space", a character that visibly separates words on a line.

The following are equivalent definitions:

  • TRUE for Unicode White_Space characters except for "vertical space controls" where "vertical space controls" are the following characters: U+000A (LF) U+000B (VT) U+000C (FF) U+000D (CR) U+0085 (NEL) U+2028 (LS) U+2029 (PS)
  • TRUE for U+0009 (TAB) and characters with general category "Zs" (space separators) except Zero Width Space (ZWSP, U+200B).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is either a "blank" or "horizontal space" character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isblank("A"));
var_dump(IntlChar::isblank(" "));
var_dump(IntlChar::isblank("\t"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(true)
   

See Also



IntlChar::iscntrl

(PHP 7)

IntlChar::iscntrlCheck if code point is a control character

Description

public static IntlChar::iscntrl ( mixed $codepoint ) : bool

Determines whether the specified code point is a control character.

A control character is one of the following:

  • ISO 8-bit control character (U+0000..U+001f and U+007f..U+009f)
  • IntlChar::CHAR_CATEGORY_CONTROL_CHAR (Cc)
  • IntlChar::CHAR_CATEGORY_FORMAT_CHAR (Cf)
  • IntlChar::CHAR_CATEGORY_LINE_SEPARATOR (Zl)
  • IntlChar::CHAR_CATEGORY_PARAGRAPH_SEPARATOR (Zp)

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a control character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::iscntrl("A"));
var_dump(IntlChar::iscntrl(" "));
var_dump(IntlChar::iscntrl("\n"));
var_dump(IntlChar::iscntrl("\u{200e}"));
?>

The above example will output:

   bool(false)
   bool(false)
   bool(true)
   bool(true)
   

See Also

  • IntlChar::isprint() - Check if code point is a printable character
  • IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT



IntlChar::isdefined

(PHP 7)

IntlChar::isdefinedCheck whether the code point is defined

Description

public static IntlChar::isdefined ( mixed $codepoint ) : bool

Determines whether the specified code point is "defined", which usually means that it is assigned a character.

TRUE for general categories other than "Cn" (other, not assigned).

Note:

Note that non-character code points (e.g., U+FDD0) are not "defined" (they are Cn), but surrogate code points are "defined" (Cs).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a defined character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isdefined("A"));
var_dump(IntlChar::isdefined(" "));
var_dump(IntlChar::isdefined("\u{FDD0}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   

See Also



IntlChar::isdigit

(PHP 7)

IntlChar::isdigitCheck if code point is a digit character

Description

public static IntlChar::isdigit ( mixed $codepoint ) : bool

Determines whether the specified code point is a digit character.

TRUE for characters with general category "Nd" (decimal digit numbers). Beginning with Unicode 4, this is the same as testing for the Numeric_Type of Decimal.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a digit character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isdigit("A"));
var_dump(IntlChar::isdigit("1"));
var_dump(IntlChar::isdigit("\t"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   

See Also



IntlChar::isgraph

(PHP 7)

IntlChar::isgraphCheck if code point is a graphic character

Description

public static IntlChar::isgraph ( mixed $codepoint ) : bool

Determines whether the specified code point is a "graphic" character (printable, excluding spaces).

TRUE for all characters except those with general categories "Cc" (control codes), "Cf" (format controls), "Cs" (surrogates), "Cn" (unassigned), and "Z" (separators).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a "graphic" character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isgraph("A"));
var_dump(IntlChar::isgraph("1"));
var_dump(IntlChar::isgraph("\u{2603}"));
var_dump(IntlChar::isgraph("\n"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(true)
   bool(false)
   


IntlChar::isIDIgnorable

(PHP 7)

IntlChar::isIDIgnorableCheck if code point is an ignorable character

Description

public static IntlChar::isIDIgnorable ( mixed $codepoint ) : bool

Determines if the specified character should be regarded as an ignorable character in an identifier.

TRUE for characters with general category "Cf" (format controls) as well as non-whitespace ISO controls (U+0000..U+0008, U+000E..U+001B, U+007F..U+009F).

Note:

Note that Unicode just recommends to ignore Cf (format controls).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is ignorable in identifiers, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isIDIgnorable("A"));
var_dump(IntlChar::isIDIgnorable(" "));
var_dump(IntlChar::isIDIgnorable("\u{007F}"));
?>

The above example will output:

   bool(false)
   bool(false)
   bool(true)
   

See Also

  • IntlChar::isIDStart() - Check if code point is permissible as the first character in an identifier
  • IntlChar::isIDPart() - Check if code point is permissible in an identifier
  • IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT



IntlChar::isIDPart

(PHP 7)

IntlChar::isIDPartCheck if code point is permissible in an identifier

Description

public static IntlChar::isIDPart ( mixed $codepoint ) : bool

Determines if the specified character is permissible in an identifier.

TRUE for characters with general categories "L" (letters), "Nl" (letter numbers), "Nd" (decimal digits), "Mc" and "Mn" (combining marks), "Pc" (connecting punctuation), and u_isIDIgnorable(c).

Note:

This is almost the same as Unicode's ID_Continue (IntlChar::PROPERTY_ID_CONTINUE) except that Unicode recommends to ignore Cf which is less than IntlChar::isIDIgnorable().

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is the code point may occur in an identifier, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isIDPart("A"));
var_dump(IntlChar::isIDPart("$"));
var_dump(IntlChar::isIDPart("\n"));
var_dump(IntlChar::isIDPart("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(false)
   bool(false)
   

See Also



IntlChar::isIDStart

(PHP 7)

IntlChar::isIDStartCheck if code point is permissible as the first character in an identifier

Description

public static IntlChar::isIDStart ( mixed $codepoint ) : bool

Determines if the specified character is permissible as the first character in an identifier according to Unicode (The Unicode Standard, Version 3.0, chapter 5.16 Identifiers).

TRUE for characters with general categories "L" (letters) and "Nl" (letter numbers).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint may start an identifier, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isIDStart("A"));
var_dump(IntlChar::isIDStart("$"));
var_dump(IntlChar::isIDStart("\n"));
var_dump(IntlChar::isIDStart("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(false)
   bool(false)
   

See Also



IntlChar::isISOControl

(PHP 7)

IntlChar::isISOControlCheck if code point is an ISO control code

Description

public static IntlChar::isISOControl ( mixed $codepoint ) : bool

Determines whether the specified code point is an ISO control code.

TRUE for U+0000..U+001f and U+007f..U+009f (general category "Cc").

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is an ISO control code, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isISOControl(" "));
var_dump(IntlChar::isISOControl("\n"));
var_dump(IntlChar::isISOControl("\u{200e}"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   

See Also



IntlChar::isJavaIDPart

(PHP 7)

IntlChar::isJavaIDPartCheck if code point is permissible in a Java identifier

Description

public static IntlChar::isJavaIDPart ( mixed $codepoint ) : bool

Determines if the specified character is permissible in a Java identifier.

In addition to IntlChar::isIDPart(), TRUE for characters with general category "Sc" (currency symbols).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint may occur in a Java identifier, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isJavaIDPart("A"));
var_dump(IntlChar::isJavaIDPart("$"));
var_dump(IntlChar::isJavaIDPart("\n"));
var_dump(IntlChar::isJavaIDPart("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isJavaIDStart

(PHP 7)

IntlChar::isJavaIDStartCheck if code point is permissible as the first character in a Java identifier

Description

public static IntlChar::isJavaIDStart ( mixed $codepoint ) : bool

Determines if the specified character is permissible as the start of a Java identifier.

In addition to IntlChar::isIDStart(), TRUE for characters with general categories "Sc" (currency symbols) and "Pc" (connecting punctuation).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint may start a Java identifier, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isJavaIDStart("A"));
var_dump(IntlChar::isJavaIDStart("$"));
var_dump(IntlChar::isJavaIDStart("\n"));
var_dump(IntlChar::isJavaIDStart("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isJavaSpaceChar

(PHP 7)

IntlChar::isJavaSpaceCharCheck if code point is a space character according to Java

Description

public static IntlChar::isJavaSpaceChar ( mixed $codepoint ) : bool

Determine if the specified code point is a space character according to Java.

TRUE for characters with general categories "Z" (separators), which does not include control codes (e.g., TAB or Line Feed).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a space character according to Java, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isJavaSpaceChar("A"));
var_dump(IntlChar::isJavaSpaceChar(" "));
var_dump(IntlChar::isJavaSpaceChar("\n"));
var_dump(IntlChar::isJavaSpaceChar("\t"));
var_dump(IntlChar::isJavaSpaceChar("\u{00A0}"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   bool(false)
   bool(true)
   

See Also



IntlChar::islower

(PHP 7)

IntlChar::islowerCheck if code point is a lowercase letter

Description

public static IntlChar::islower ( mixed $codepoint ) : bool

Determines whether the specified code point has the general category "Ll" (lowercase letter).

Note:

This misses some characters that are also lowercase but have a different general category value. In order to include those, use IntlChar::isULowercase().

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is an Ll lowercase letter, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::islower("A"));
var_dump(IntlChar::islower("a"));
var_dump(IntlChar::islower("Φ"));
var_dump(IntlChar::islower("φ"));
var_dump(IntlChar::islower("1"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   bool(true)
   bool(false)
   

See Also



IntlChar::isMirrored

(PHP 7)

IntlChar::isMirroredCheck if code point has the Bidi_Mirrored property

Description

public static IntlChar::isMirrored ( mixed $codepoint ) : bool

Determines whether the code point has the Bidi_Mirrored property.

This property is set for characters that are commonly used in Right-To-Left contexts and need to be displayed with a "mirrored" glyph.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint has the Bidi_Mirrored property, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isMirrored("A"));
var_dump(IntlChar::isMirrored("<"));
var_dump(IntlChar::isMirrored("("));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(true)
   

See Also



IntlChar::isprint

(PHP 7)

IntlChar::isprintCheck if code point is a printable character

Description

public static IntlChar::isprint ( mixed $codepoint ) : bool

Determines whether the specified code point is a printable character.

TRUE for general categories other than "C" (controls).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a printable character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isprint("A"));
var_dump(IntlChar::isprint(" "));
var_dump(IntlChar::isprint("\n"));
var_dump(IntlChar::isprint("\u{200e}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   bool(false)
   

See Also

  • IntlChar::iscntrl() - Check if code point is a control character
  • IntlChar::PROPERTY_DEFAULT_IGNORABLE_CODE_POINT



IntlChar::ispunct

(PHP 7)

IntlChar::ispunctCheck if code point is punctuation character

Description

public static IntlChar::ispunct ( mixed $codepoint ) : bool

Determines whether the specified code point is a punctuation character.

TRUE for characters with general categories "P" (punctuation).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a punctuation character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::ispunct("."));
var_dump(IntlChar::ispunct(","));
var_dump(IntlChar::ispunct("\n"));
var_dump(IntlChar::ispunct("$"));

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   bool(false)
   


IntlChar::isspace

(PHP 7)

IntlChar::isspaceCheck if code point is a space character

Description

public static IntlChar::isspace ( mixed $codepoint ) : bool

Determines if the specified character is a space character or not.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a space character, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isspace("A"));
var_dump(IntlChar::isspace(" "));
var_dump(IntlChar::isspace("\n"));
var_dump(IntlChar::isspace("\t"));
var_dump(IntlChar::isspace("\u{00A0}"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(true)
   bool(true)
   bool(true)
   

See Also



IntlChar::istitle

(PHP 7)

IntlChar::istitleCheck if code point is a titlecase letter

Description

public static IntlChar::istitle ( mixed $codepoint ) : bool

Determines whether the specified code point is a titlecase letter.

TRUE for general category "Lt" (titlecase letter).

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a titlecase letter, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::istitle("A"));
var_dump(IntlChar::istitle("a"));
var_dump(IntlChar::istitle("Φ"));
var_dump(IntlChar::istitle("φ"));
var_dump(IntlChar::istitle("1"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   bool(true)
   bool(false)
   

See Also



IntlChar::isUAlphabetic

(PHP 7)

IntlChar::isUAlphabeticCheck if code point has the Alphabetic Unicode property

Description

public static IntlChar::isUAlphabetic ( mixed $codepoint ) : bool

Check if a code point has the Alphabetic Unicode property.

This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_ALPHABETIC)

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint has the Alphabetic Unicode property, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isUAlphabetic("A"));
var_dump(IntlChar::isUAlphabetic("1"));
var_dump(IntlChar::isUAlphabetic("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isULowercase

(PHP 7)

IntlChar::isULowercaseCheck if code point has the Lowercase Unicode property

Description

public static IntlChar::isULowercase ( mixed $codepoint ) : bool

Check if a code point has the Lowercase Unicode property.

This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_LOWERCASE)

Note:

This is different than IntlChar::islower() and will return TRUE for more characters.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint has the Lowercase Unicode property, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isULowercase("A"));
var_dump(IntlChar::isULowercase("a"));
var_dump(IntlChar::isULowercase("Φ"));
var_dump(IntlChar::isULowercase("φ"));
var_dump(IntlChar::isULowercase("1"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(false)
   bool(true)
   bool(false)
   

See Also



IntlChar::isupper

(PHP 7)

IntlChar::isupperCheck if code point has the general category "Lu" (uppercase letter)

Description

public static IntlChar::isupper ( mixed $codepoint ) : bool

Determines whether the specified code point has the general category "Lu" (uppercase letter).

Note:

This misses some characters that are also uppercase but have a different general category value. In order to include those, use IntlChar::isUUppercase().

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is an Lu uppercase letter, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isupper("A"));
var_dump(IntlChar::isupper("a"));
var_dump(IntlChar::isupper("Φ"));
var_dump(IntlChar::isupper("φ"));
var_dump(IntlChar::isupper("1"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isUUppercase

(PHP 7)

IntlChar::isUUppercaseCheck if code point has the Uppercase Unicode property

Description

public static IntlChar::isUUppercase ( mixed $codepoint ) : bool

Check if a code point has the Uppercase Unicode property.

This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_UPPERCASE)

Note:

This is different than IntlChar::isupper() and will return TRUE for more characters.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint has the Uppercase Unicode property, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isUUppercase("A"));
var_dump(IntlChar::isUUppercase("a"));
var_dump(IntlChar::isUUppercase("Φ"));
var_dump(IntlChar::isUUppercase("φ"));
var_dump(IntlChar::isUUppercase("1"));
?>

The above example will output:

   bool(true)
   bool(false)
   bool(true)
   bool(false)
   bool(false)
   

See Also



IntlChar::isUWhiteSpace

(PHP 7)

IntlChar::isUWhiteSpaceCheck if code point has the White_Space Unicode property

Description

public static IntlChar::isUWhiteSpace ( mixed $codepoint ) : bool

Check if a code point has the White_Space Unicode property.

This is the same as IntlChar::hasBinaryProperty($codepoint, IntlChar::PROPERTY_WHITE_SPACE)

Note:

This is different from both IntlChar::isspace() and IntlChar::isWhitespace().

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint has the White_Space Unicode property, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isUWhiteSpace("A"));
var_dump(IntlChar::isUWhiteSpace(" "));
var_dump(IntlChar::isUWhiteSpace("\n"));
var_dump(IntlChar::isUWhiteSpace("\t"));
var_dump(IntlChar::isUWhiteSpace("\u{00A0}"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(true)
   bool(true)
   bool(true)
   

See Also



IntlChar::isWhitespace

(PHP 7)

IntlChar::isWhitespaceCheck if code point is a whitespace character according to ICU

Description

public static IntlChar::isWhitespace ( mixed $codepoint ) : bool

Determines if the specified code point is a whitespace character according to ICU.

A character is considered to be a ICU whitespace character if and only if it satisfies one of the following criteria:

  • It is a Unicode Separator character (categories "Z" = "Zs" or "Zl" or "Zp"), but is not also a non-breaking space (U+00A0 NBSP or U+2007 Figure Space or U+202F Narrow NBSP).
  • It is U+0009 HORIZONTAL TABULATION.
  • It is U+000A LINE FEED.
  • It is U+000B VERTICAL TABULATION.
  • It is U+000C FORM FEED.
  • It is U+000D CARRIAGE RETURN.
  • It is U+001C FILE SEPARATOR.
  • It is U+001D GROUP SEPARATOR.
  • It is U+001E RECORD SEPARATOR.
  • It is U+001F UNIT SEPARATOR.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a whitespace character according to ICU, FALSE if not.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::iswhitespace("A"));
var_dump(IntlChar::iswhitespace(" "));
var_dump(IntlChar::iswhitespace("\n"));
var_dump(IntlChar::iswhitespace("\t"));
var_dump(IntlChar::iswhitespace("\u{00A0}"));
?>

The above example will output:

   bool(false)
   bool(true)
   bool(true)
   bool(true)
   bool(false)
   

See Also



IntlChar::isxdigit

(PHP 7)

IntlChar::isxdigitCheck if code point is a hexadecimal digit

Description

public static IntlChar::isxdigit ( mixed $codepoint ) : bool

Determines whether the specified code point is a hexadecimal digit.

TRUE for characters with general category "Nd" (decimal digit numbers) as well as Latin letters a-f and A-F in both ASCII and Fullwidth ASCII. (That is, for letters with code points 0041..0046, 0061..0066, FF21..FF26, FF41..FF46.)

This is equivalent to IntlChar::digit($codepoint, 16) >= 0.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns TRUE if codepoint is a hexadecimal character, FALSE if not.

Notes

Note:

In order to narrow the definition of hexadecimal digits to only ASCII characters use:

<?php
$isASCIIHexadecimal 
IntlChar::ord($codepoint) <= 0x7F && IntlChar::isxdigit($codepoint);
?>

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::isxdigit("A"));
var_dump(IntlChar::isxdigit("1"));
var_dump(IntlChar::isxdigit("\u{2603}"));
?>

The above example will output:

   bool(true)
   bool(true)
   bool(false)
   

See Also



IntlChar::ord

(PHP 7)

IntlChar::ordReturn Unicode code point value of character

Description

public static IntlChar::ord ( mixed $character ) : int

Returns the Unicode code point value of the given character.

This function compliments IntlChar::chr().

Parameters

character

A Unicode character.

Return Values

Returns the Unicode code point value as an integer.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::ord("A"));
var_dump(IntlChar::ord(" "));
var_dump(IntlChar::ord("\u{2603}"));
?>

The above example will output:

   int(65)
   int(32)
   int(9731)
   

See Also



IntlChar::tolower

(PHP 7)

IntlChar::tolowerMake Unicode character lowercase

Description

public static IntlChar::tolower ( mixed $codepoint ) : mixed

The given character is mapped to its lowercase equivalent. If the character has no lowercase equivalent, the original character itself is returned.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the Simple_Lowercase_Mapping of the code point, if any; otherwise the code point itself.

The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::tolower("A"));
var_dump(IntlChar::tolower("a"));
var_dump(IntlChar::tolower("Φ"));
var_dump(IntlChar::tolower("φ"));
var_dump(IntlChar::tolower("1"));
var_dump(IntlChar::tolower(ord("A")));
var_dump(IntlChar::tolower(ord("a")));
?>

The above example will output:

   string(1) "a"
   string(1) "a"
   string(2) "φ"
   string(2) "φ"
   string(1) "1"
   int(97)
   int(97)
   

See Also



IntlChar::totitle

(PHP 7)

IntlChar::totitleMake Unicode character titlecase

Description

public static IntlChar::totitle ( mixed $codepoint ) : mixed

The given character is mapped to its titlecase equivalent. If the character has no titlecase equivalent, the original character itself is returned.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the Simple_Titlecase_Mapping of the code point, if any; otherwise the code point itself.

The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::totitle("A"));
var_dump(IntlChar::totitle("a"));
var_dump(IntlChar::totitle("Φ"));
var_dump(IntlChar::totitle("φ"));
var_dump(IntlChar::totitle("1"));
var_dump(IntlChar::totitle(ord("A")));
var_dump(IntlChar::totitle(ord("a")));
?>

The above example will output:

   string(1) "A"
   string(1) "A"
   string(2) "Φ"
   string(2) "Φ"
   string(1) "1"
   int(65)
   int(65)
   

See Also



IntlChar::toupper

(PHP 7)

IntlChar::toupperMake Unicode character uppercase

Description

public static IntlChar::toupper ( mixed $codepoint ) : mixed

The given character is mapped to its uppercase equivalent. If the character has no uppercase equivalent, the character itself is returned.

Parameters

codepoint

The integer codepoint value (e.g. 0x2603 for U+2603 SNOWMAN), or the character encoded as a UTF-8 string (e.g. "\u{2603}")

Return Values

Returns the Simple_Uppercase_Mapping of the code point, if any; otherwise the code point itself.

The return type will be integer unless the code point was passed as a UTF-8 string, in which case a string will be returned.

Examples

Example #1 Testing different code points

<?php
var_dump
(IntlChar::toupper("A"));
var_dump(IntlChar::toupper("a"));
var_dump(IntlChar::toupper("Φ"));
var_dump(IntlChar::toupper("φ"));
var_dump(IntlChar::toupper("1"));
var_dump(IntlChar::toupper(ord("A")));
var_dump(IntlChar::toupper(ord("a")));
?>

The above example will output:

   string(1) "A"
   string(1) "A"
   string(2) "Φ"
   string(2) "Φ"
   string(1) "1"
   int(65)
   int(65)
   

See Also


Table of Contents



Exception class for intl errors

(PHP 5 > 5.5.0, PHP 7, PECL intl > 3.0.0a1)

Introduction

This class is used for generating exceptions when errors occur inside intl functions. Such exceptions are only generated when intl.use_exceptions is enabled.

Class synopsis

IntlException extends Exception {
/* Inherited properties */
protected string message ;
protected int code ;
protected string file ;
protected int line ;
/* Inherited methods */
final public Exception::getMessage ( void ) : string
final public Exception::getPrevious ( void ) : Throwable
final public Exception::getCode ( void ) : mixed
final public Exception::getFile ( void ) : string
final public Exception::getLine ( void ) : int
final public Exception::getTrace ( void ) : array
final public Exception::getTraceAsString ( void ) : string
public Exception::__toString ( void ) : string
final private Exception::__clone ( void ) : void
}


The IntlIterator class

(PHP 5 >= 5.5.0, PHP 7)

Introduction

This class represents iterator objects throughout the intl extension whenever the iterator cannot be identified with any other object provided by the extension. The distinct iterator object used internally by the foreach construct can only be obtained (in the relevant part here) from objects, so objects of this class serve the purpose of providing the hook through which this internal object can be obtained. As a convenience, this class also implements the Iterator interface, allowing the collection of values to be navigated using the methods defined in that interface. Both these methods and the internal iterator objects provided to foreach are backed by the same state (e.g. the position of the iterator and its current value).

Subclasses may provide richer functionality.

Class synopsis

IntlIterator implements Iterator {
/* Methods */
public current ( void ) : mixed
public key ( void ) : string
public next ( void ) : void
public rewind ( void ) : void
public valid ( void ) : bool
}

IntlIterator::current

(PHP 5 >= 5.5.0, PHP 7)

IntlIterator::currentGet the current element

Description

public IntlIterator::current ( void ) : mixed

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlIterator::key

(PHP 5 >= 5.5.0, PHP 7)

IntlIterator::keyGet the current key

Description

public IntlIterator::key ( void ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlIterator::next

(PHP 5 >= 5.5.0, PHP 7)

IntlIterator::nextMove forward to the next element

Description

public IntlIterator::next ( void ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlIterator::rewind

(PHP 5 >= 5.5.0, PHP 7)

IntlIterator::rewindRewind the iterator to the first element

Description

public IntlIterator::rewind ( void ) : void

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values



IntlIterator::valid

(PHP 5 >= 5.5.0, PHP 7)

IntlIterator::validCheck if current position is valid

Description

public IntlIterator::valid ( void ) : bool

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values


Table of Contents



intl Functions


intl_error_name

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

intl_error_nameGet symbolic name for a given error code

Description

intl_error_name ( int $error_code ) : string

Return ICU error code name.

Parameters

error_code

ICU error code.

Return Values

The returned string will be the same as the name of the error code constant.

Examples

Example #1 intl_error_name() example

<?php
$coll     
collator_create'en_RU' );
$err_code collator_get_error_code$coll );

printf"Symbolic name for %d is %s\n."$err_codeintl_error_name$err_code ) );
?>

The above example will output something similar to:

   Symbolic name for -128 is U_USING_FALLBACK_WARNING.
   

See Also



intl_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

intl_get_error_codeGet the last error code

Description

intl_get_error_code ( void ) : int

Useful to handle errors occurred in static methods when there's no object to get error code from.

Return Values

Error code returned by the last API function call.

Examples

Example #1 intl_get_error_code() example

<?php
$coll 
collator_create'<bad_param>' );
if( !
$coll ) {
    
handle_errorintl_get_error_code() );
}
?>

See Also



intl_get_error_message

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

intl_get_error_messageGet description of the last error

Description

intl_get_error_message ( void ) : string

Get error message from last internationalization function called.

Return Values

Description of an error occurred in the last API function call.

Examples

Example #1 intl_get_error_message() example

<?php
if( Collator::getAvailableLocales() === false ) {
    
show_errorintl_get_error_message() );
}
?>

See Also



intl_is_failure

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

intl_is_failureCheck whether the given error code indicates failure

Description

intl_is_failure ( int $error_code ) : bool

Parameters

error_code

is a value that returned by functions: intl_get_error_code(), collator_get_error_code() .

Return Values

TRUE if it the code indicates some failure, and FALSE in case of success or a warning.

Examples

Example #1 intl_is_failure() example

<?php
function check$err_code )
{
    
var_exportintl_is_failure$err_code ) );
    echo 
"\n";
}

checkU_ZERO_ERROR );
checkU_USING_FALLBACK_WARNING );
checkU_ILLEGAL_ARGUMENT_ERROR );
?>

The above example will output something similar to:

   false
   false
   true
   

See Also


Table of Contents




Multibyte String


Introduction

While there are many languages in which every necessary character can be represented by a one-to-one mapping to an 8-bit value, there are also several languages which require so many characters for written communication that they cannot be contained within the range a mere byte can code (A byte is made up of eight bits. Each bit can contain only two distinct values, one or zero. Because of this, a byte can only represent 256 unique values (two to the power of eight)). Multibyte character encoding schemes were developed to express more than 256 characters in the regular bytewise coding system.

When you manipulate (trim, split, splice, etc.) strings encoded in a multibyte encoding, you need to use special functions since two or more consecutive bytes may represent a single character in such encoding schemes. Otherwise, if you apply a non-multibyte-aware string function to the string, it probably fails to detect the beginning or ending of the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning.

mbstring provides multibyte specific string functions that help you deal with multibyte encodings in PHP. In addition to that, mbstring handles character encoding conversion between the possible encoding pairs. mbstring is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience (listed below).



Installing/Configuring

Table of Contents


Requirements

No external libraries are needed to build this extension.



Installation

mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option. See the Install section for details.

The following configure options are related to the mbstring module.

  • --enable-mbstring: Enable mbstring functions. This option is required to use mbstring functions.

    libmbfl is necessary for mbstring. libmbfl is bundled with mbstring. Before PHP 7.3.0, if libmbfl is already installed on the system, --with-libmbfl[=DIR] can be specified to use the installed library.

  • --disable-mbregex: Disable regular expression functions with multibyte character support.

    Oniguruma is necessary for the regular expression functions with multibyte character support. Oniguruma is bundled with mbstring. As of PHP 5.4.0, if Oniguruma is already installed on the system, --with-onig[=DIR] can be specified to use the installed library. As of PHP 7.4.0 --with-onig has been removed and pkg-config is now used to detect the libonig library.

    As of PHP 5.4.0 it is possible to disable the multibyte regex backtrack check by specifying --disable-mbregex-backtrack.



Runtime Configuration

The behaviour of these functions is affected by settings in php.ini.

mbstring configuration options
Name Default Changeable Changelog
mbstring.language "neutral" PHP_INI_ALL PHP_INI_PERDIR in PHP <= 5.2.6.
mbstring.detect_order NULL PHP_INI_ALL  
mbstring.http_input "pass" PHP_INI_ALL Deprecated in PHP 5.6.0.
mbstring.http_output "pass" PHP_INI_ALL Deprecated in PHP 5.6.0.
mbstring.internal_encoding NULL PHP_INI_ALL Deprecated in PHP 5.6.0.
mbstring.script_encoding NULL PHP_INI_ALL Removed in PHP 5.4.0. Use zend.script_encoding instead.
mbstring.substitute_character NULL PHP_INI_ALL  
mbstring.func_overload "0" PHP_INI_SYSTEM PHP_INI_PERDIR in PHP <= 5.2.6. Deprecated in PHP 7.2.0.
mbstring.encoding_translation "0" PHP_INI_PERDIR  
mbstring.http_output_conv_mimetypes "^(text/|application/xhtml\+xml)" PHP_INI_ALL Available as of PHP 5.3.0.
mbstring.strict_detection "0" PHP_INI_ALL Available as of PHP 5.1.2.
For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set.

Here's a short explanation of the configuration directives.

mbstring.language string

The default national language setting (NLS) used in mbstring. Note that this option automagically defines mbstring.internal_encoding and mbstring.internal_encoding should be placed after mbstring.language in php.ini

mbstring.encoding_translation boolean

Enables the transparent character encoding filter for the incoming HTTP queries, which performs detection and conversion of the input encoding to the internal character encoding.

mbstring.internal_encoding string
Warning

This feature has been DEPRECATED as of PHP 5.6.0. Relying on this feature is highly discouraged.

Defines the default internal character encoding.

PHP 5.6 and later users should leave this empty and set default_charset instead.

mbstring.http_input string
Warning

This feature has been DEPRECATED as of PHP 5.6.0. Relying on this feature is highly discouraged.

Defines the default HTTP input character encoding.

PHP 5.6 and later users should leave this empty and set default_charset instead.

mbstring.http_output string
Warning

This feature has been DEPRECATED as of PHP 5.6.0. Relying on this feature is highly discouraged.

Defines the default HTTP output character encoding (output will be converted from the internal encoding to the HTTP output encoding upon output).

PHP 5.6 and later users should leave this empty and set default_charset instead.

mbstring.detect_order string

Defines default character code detection order. See also mb_detect_order().

mbstring.substitute_character string

Defines character to substitute for invalid character encoding. See mb_substitute_character() for supported values.

mbstring.func_overload string
Warning

This feature has been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged.

Overloads a set of single byte functions by the mbstring counterparts. See Function overloading for more information.

This setting can only be changed from the php.ini file.

mbstring.http_output_conv_mimetypes string

mbstring.strict_detection boolean

Enables the strict encoding detection.

According to the » HTML 4.01 specification, Web browsers are allowed to encode a form being submitted with a character encoding different from the one used for the page. See mb_http_input() to detect character encoding used by browsers.

Although popular browsers are capable of giving a reasonably accurate guess to the character encoding of a given HTML document, it would be better to set the charset parameter in the Content-Type HTTP header to the appropriate value by header() or default_charset ini setting.

Example #1 php.ini setting examples

   ; Set default language
   mbstring.language        = Neutral; Set default language to Neutral(UTF-8) (default)
   mbstring.language        = English; Set default language to English 
   mbstring.language        = Japanese; Set default language to Japanese
   
   ;; Set default internal encoding
   ;; Note: Make sure to use character encoding works with PHP
   mbstring.internal_encoding    = UTF-8  ; Set internal encoding to UTF-8
   
   ;; HTTP input encoding translation is enabled.
   mbstring.encoding_translation = On
   
   ;; Set default HTTP input character encoding
   ;; Note: Script cannot change http_input setting.
   mbstring.http_input           = pass    ; No conversion. 
   mbstring.http_input           = auto    ; Set HTTP input to auto
                                   ; "auto" is expanded according to mbstring.language
   mbstring.http_input           = SJIS    ; Set HTTP input to SJIS
   mbstring.http_input           = UTF-8,SJIS,EUC-JP ; Specify order
   
   ;; Set default HTTP output character encoding 
   mbstring.http_output          = pass    ; No conversion
   mbstring.http_output          = UTF-8   ; Set HTTP output encoding to UTF-8
   
   ;; Set default character encoding detection order
   mbstring.detect_order         = auto    ; Set detect order to auto
   mbstring.detect_order         = ASCII,JIS,UTF-8,SJIS,EUC-JP ; Specify order
   
   ;; Set default substitute character
   mbstring.substitute_character = 12307   ; Specify Unicode value
   mbstring.substitute_character = none    ; Do not print character
   mbstring.substitute_character = long    ; Long Example: U+3000,JIS+7E7E
   

Example #2 php.ini setting for EUC-JP users

   ;; Disable Output Buffering
   output_buffering      = Off
   
   ;; Set HTTP header charset
   default_charset       = EUC-JP    
   
   ;; Set default language to Japanese
   mbstring.language = Japanese
   
   ;; HTTP input encoding translation is enabled.
   mbstring.encoding_translation = On
   
   ;; Set HTTP input encoding conversion to auto
   mbstring.http_input   = auto 
   
   ;; Convert HTTP output to EUC-JP
   mbstring.http_output  = EUC-JP    
   
   ;; Set internal encoding to EUC-JP
   mbstring.internal_encoding = EUC-JP    
   
   ;; Do not print invalid characters
   mbstring.substitute_character = none   
   

Example #3 php.ini setting for SJIS users

   ;; Enable Output Buffering
   output_buffering     = On
   
   ;; Set mb_output_handler to enable output conversion
   output_handler       = mb_output_handler
   
   ;; Set HTTP header charset
   default_charset      = Shift_JIS
   
   ;; Set default language to Japanese
   mbstring.language = Japanese
   
   ;; Set http input encoding conversion to auto
   mbstring.http_input  = auto 
   
   ;; Convert to SJIS
   mbstring.http_output = SJIS    
   
   ;; Set internal encoding to EUC-JP
   mbstring.internal_encoding = EUC-JP    
   
   ;; Do not print invalid characters
   mbstring.substitute_character = none   
   



Resource Types

This extension has no resource types defined.




Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

MB_OVERLOAD_MAIL (integer)
MB_OVERLOAD_STRING (integer)
MB_OVERLOAD_REGEX (integer)
MB_CASE_UPPER (integer)
Performs a full upper-case folding. This may change the length of the string. This is the mode used by mb_strtoupper().
MB_CASE_LOWER (integer)
Performs a full lower-case folding. This may change the length of the string. This is the mode used by mb_strtolower().
MB_CASE_TITLE (integer)
Performs a full title-case conversion based on the Cased and CaseIgnorable derived Unicode properties. In particular this improves handling of quotes and apostrophes. This may change the length of the string.
MB_CASE_FOLD (integer)
Performs a full case fold conversion which removes case distinctions present in the string. This is used for caseless matching. This may change the length of the string. Available since PHP 7.3.
MB_CASE_LOWER_SIMPLE (integer)
Performs a simple lower-case fold conversion. This does not change the length of the string. Available as of PHP 7.3.
MB_CASE_UPPER_SIMPLE (integer)
Performs simple upper-case fold conversion. This does not change the length of the string. Available as of PHP 7.3.
MB_CASE_TITLE_SIMPLE (integer)
Performs simple title-case fold conversion. This does not change the length of the string. Available as of PHP 7.3.
MB_CASE_FOLD_SIMPLE (integer)
Performs a simple case fold conversion which removes case distinctions present in the string. This is used for caseless matching. This does not change the length of the string. Used by case-insensitive operations internally by the MBString extension. Available as of PHP 7.3.
MB_ONIGURUMA_VERSION (string)
The Oniguruma version, e.g. 6.9.4. Available as of PHP 7.4.


Summaries of supported encodings

Summaries of supported encodings
Name in the IANA character set registry Underlying character set Description Additional note
ISO-10646-UCS-4 ISO 10646 The Universal Character Set with 31-bit code space, standardized as UCS-4 by ISO/IEC 10646. It is kept synchronized with the latest version of the Unicode code map. If this name is used in the encoding conversion facility, the converter attempts to identify by the preceding BOM (byte order mark)in which endian the subsequent bytes are represented.
ISO-10646-UCS-4 UCS-4 See above. In contrast to UCS-4, strings are always assumed to be in big endian form.
ISO-10646-UCS-4 UCS-4 See above. In contrast to UCS-4, strings are always assumed to be in little endian form.
ISO-10646-UCS-2 UCS-2 The Universal Character Set with 16-bit code space, standardized as UCS-2 by ISO/IEC 10646. It is kept synchronized with the latest version of the unicode code map. If this name is used in the encoding conversion facility, the converter attempts to identify by the preceding BOM (byte order mark)in which endian the subsequent bytes are represented.
ISO-10646-UCS-2 UCS-2 See above. In contrast to UCS-2, strings are always assumed to be in big endian form.
ISO-10646-UCS-2 UCS-2 See above. In contrast to UCS-2, strings are always assumed to be in little endian form.
UTF-32 Unicode Unicode Transformation Format of 32-bit unit width, whose encoding space refers to the Unicode's codeset standard. This encoding scheme wasn't identical to UCS-4 because the code space of Unicode were limited to a 21-bit value. If this name is used in the encoding conversion facility, the converter attempts to identify by the preceding BOM (byte order mark)in which endian the subsequent bytes are represented.
UTF-32BE Unicode See above In contrast to UTF-32, strings are always assumed to be in big endian form.
UTF-32LE Unicode See above In contrast to UTF-32, strings are always assumed to be in little endian form.
UTF-16 Unicode Unicode Transformation Format of 16-bit unit width. It's worth a note that UTF-16 is no longer the same specification as UCS-2 because the surrogate mechanism has been introduced since Unicode 2.0 and UTF-16 now refers to a 21-bit code space. If this name is used in the encoding conversion facility, the converter attempts to identify by the preceding BOM (byte order mark)in which endian the subsequent bytes are represented.
UTF-16BE Unicode See above. In contrast to UTF-16, strings are always assumed to be in big endian form.
UTF-16LE Unicode See above. In contrast to UTF-16, strings are always assumed to be in little endian form.
UTF-8 Unicode / UCS Unicode Transformation Format of 8-bit unit width. none
UTF-7 Unicode A mail-safe transformation format of Unicode, specified in » RFC2152. none
(none) Unicode A variant of UTF-7 which is specialized for use in the » IMAP protocol. none
US-ASCII (preferred MIME name) / iso-ir-6 / ANSI_X3.4-1986 / ISO_646.irv:1991 / ASCII / ISO646-US / us / IBM367 / CP367 / csASCII ASCII / ISO 646 American Standard Code for Information Interchange is a commonly-used 7-bit encoding. Also standardized as an international standard, ISO 646. (none)
EUC-JP (preferred MIME name) / Extended_UNIX_Code_Packed_Format_for_Japanese / csEUCPkdFmtJapanese Compound of US-ASCII / JIS X0201:1997 (hankaku kana part) / JIS X0208:1990 / JIS X0212:1990 As you see the name is derived from an abbreviation of Extended UNIX Code Packed Format for Japanese, this encoding is mostly used on UNIX or alike platforms. The original encoding scheme, Extended UNIX Code, is designed on the basis of ISO 2022. The character set referred to by EUC-JP is different to IBM932 / CP932, which are used by OS/2® and Microsoft® Windows®. For information interchange with those platforms, use EUCJP-WIN instead.
Shift_JIS (preferred MIME name) / MS_Kanji / csShift_JIS Compound of JIS X0201:1997 / JIS X0208:1997 Shift_JIS was developed in early 80's, at the time personal Japanese word processors were brought into the market, in order to maintain compatibilities with the legacy encoding scheme JIS X 0201:1976. According to the IANA definition the codeset of Shift_JIS is slightly different to IBM932 / CP932. However, the names "SJIS" / "Shift_JIS" are often wrongly used to refer to these codesets. For the CP932 codemap, use SJIS-WIN instead.
(none) Compound of JIS X0201:1997 / JIS X0208:1997 / IBM extensions / NEC extensions While this "encoding" uses the same encoding scheme as EUC-JP, the underlying character set is different. That is, some code points map to different characters than EUC-JP. none
Windows-31J / csWindows31J Compound of JIS X0201:1997 / JIS X0208:1997 / IBM extensions / NEC extensions While this "encoding" uses the same encoding scheme as Shift_JIS, the underlying character set is different. That means some code points map to different characters than Shift_JIS. (none)
ISO-2022-JP (preferred MIME name) / csISO2022JP US-ASCII / JIS X0201:1976 / JIS X0208:1978 / JIS X0208:1983 » RFC1468 (none)
JIS
ISO-8859-1
ISO-8859-2
ISO-8859-3
ISO-8859-4
ISO-8859-5
ISO-8859-6
ISO-8859-7
ISO-8859-8
ISO-8859-9
ISO-8859-10
ISO-8859-13
ISO-8859-14
ISO-8859-15
ISO-8859-16
byte2be
byte2le
byte4be
byte4le
BASE64
HTML-ENTITIES
7bit
8bit
EUC-CN
CP936
HZ
EUC-TW
CP950
BIG-5
EUC-KR
UHC (CP949)
ISO-2022-KR
Windows-1251 (CP1251)
Windows-1252 (CP1252)
CP866 (IBM866)
KOI8-R
KOI8-U


Basics of Japanese multi-byte encodings

Japanese characters can only be represented by multibyte encodings, and multiple encoding standards are used depending on platform and text purpose. To make matters worse, these encoding standards differ slightly from one another. In order to create a web application which would be usable in a Japanese environment, a developer has to keep these complexities in mind to ensure that the proper character encodings are used.



HTTP Input and Output

HTTP input/output character encoding conversion may convert binary data also. Users are supposed to control character encoding conversion if binary data is used for HTTP input/output.

Note:

If enctype for HTML form is set to multipart/form-data and mbstring.encoding_translation is set to On in php.ini the POST'ed variables and the names of uploaded files will be converted to the internal character encoding as well. However, the conversion isn't applied to the query keys.

Example #2 php.ini setting example

   ;; Enable output character encoding conversion for all PHP pages
   
   ;; Enable Output Buffering
   output_buffering    = On
   
   ;; Set mb_output_handler to enable output conversion
   output_handler      = mb_output_handler
   

Example #3 Script example

<?php

// Enable output character encoding conversion only for this page

// Set HTTP output character encoding to SJIS
mb_http_output('SJIS');

// Start buffering and specify "mb_output_handler" as
// callback function
ob_start('mb_output_handler');

?>



Supported Character Encodings

Currently the following character encodings are supported by the mbstring module. Any of those Character encodings can be specified in the encoding parameter of mbstring functions.

The following character encodings are supported in this PHP extension:

* denotes encodings usable also in regular expressions.

** denotes encodings available since PHP 5.4.0.

Any php.ini entry which accepts an encoding name can also use the values "auto" and "pass". mbstring functions which accept an encoding name can also use the value "auto".

If "pass" is set, no character encoding conversion is performed.

If "auto" is set, it is expanded to the list of encodings defined per the NLS. For instance, if the NLS is set to Japanese, the value is assumed to be "ASCII,JIS,UTF-8,EUC-JP,SJIS".

See also mb_detect_order()



Function Overloading Feature

Warning

This feature has been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged.

You might often find it difficult to get an existing PHP application to work in a given multibyte environment. This happens because most PHP applications out there are written with the standard string functions such as substr(), which are known to not properly handle multibyte-encoded strings.

mbstring supports a 'function overloading' feature which enables you to add multibyte awareness to such an application without code modification by overloading multibyte counterparts on the standard string functions. For example, mb_substr() is called instead of substr() if function overloading is enabled. This feature makes it easy to port applications that only support single-byte encodings to a multibyte environment in many cases.

To use function overloading, set mbstring.func_overload in php.ini to a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions. For example, if it is set to 7, mail, strings and regular expression functions will be overloaded. The list of overloaded functions are shown below.
Functions to be overloaded
value of mbstring.func_overload original function overloaded function
1 mail() mb_send_mail()
2 strlen() mb_strlen()
2 strpos() mb_strpos()
2 strrpos() mb_strrpos()
2 substr() mb_substr()
2 strtolower() mb_strtolower()
2 strtoupper() mb_strtoupper()
2 stripos() mb_stripos()
2 strripos() mb_strripos()
2 strstr() mb_strstr()
2 stristr() mb_stristr()
2 strrchr() mb_strrchr()
2 substr_count() mb_substr_count()
4 ereg() mb_ereg()
4 eregi() mb_eregi()
4 ereg_replace() mb_ereg_replace()
4 eregi_replace() mb_eregi_replace()
4 split() mb_split()

Note:

It is not recommended to use the function overloading option in the per-directory context, because it's not confirmed yet to be stable enough in a production environment and may lead to undefined behaviour.



PHP Character Encoding Requirements

Encodings of the following types are safely used with PHP.

These are examples of character encodings that are unlikely to work with PHP.

   JIS, SJIS, ISO-2022-JP, BIG-5
   

Although PHP scripts written in any of those encodings might not work, especially in the case where encoded strings appear as identifiers or literals in the script, you can almost avoid using these encodings by setting up the mbstring's transparent encoding filter function for incoming HTTP queries.

Note:

It's highly discouraged to use SJIS, BIG5, CP936, CP949 and GB18030 for the internal encoding unless you are familiar with the parser, the scanner and the character encoding.

Note:

If you are connecting to a database with PHP, it is recommended that you use the same character encoding for both the database and the internal encoding for ease of use and better performance.

If you are using PostgreSQL, the character encoding used in the database and the one used in PHP may differ as it supports automatic character set conversion between the backend and the frontend.



Multibyte String Functions

References

Multibyte character encoding schemes and their related issues are fairly complicated, and are beyond the scope of this documentation. Please refer to the following URLs and other resources for further information regarding these topics.


mb_check_encoding

(PHP 4 >= 4.4.3, PHP 5 >= 5.1.3, PHP 7)

mb_check_encodingCheck if strings are valid for the specified encoding

Description

mb_check_encoding ([ mixed $var = NULL [, string $encoding = mb_internal_encoding() ]] ) : bool

Checks if the specified byte stream is valid for the specified encoding. If var is of type array, all keys and values are validated recursively. It is useful to prevent so-called "Invalid Encoding Attack".

Parameters

var

The byte stream or array to check. If it is omitted, this function checks all the input from the beginning of the request.

encoding

The expected encoding.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.2.0 This function now also accepts an array as var. Formerly, only strings have been supported.


mb_chr

(PHP 7 >= 7.2.0)

mb_chrGet a specific character

Description

mb_chr ( int $cp [, string $encoding ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

cp

encoding

Return Values

Returns a specific character or FALSE on failure.

See Also

  • mb_ord() - Get code point of character
  • chr() - Generate a single-byte string from a number



mb_convert_case

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_convert_casePerform case folding on a string

Description

mb_convert_case ( string $str , int $mode [, string $encoding = mb_internal_encoding() ] ) : string

Performs case folding on a string, converted in the way specified by mode.

Parameters

str

The string being converted.

mode

The mode of the conversion. It can be one of MB_CASE_UPPER, MB_CASE_LOWER, MB_CASE_TITLE, MB_CASE_FOLD, MB_CASE_UPPER_SIMPLE, MB_CASE_LOWER_SIMPLE, MB_CASE_TITLE_SIMPLE, MB_CASE_FOLD_SIMPLE.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

A case folded version of string converted in the way specified by mode.

Unicode

By contrast to the standard case folding functions such as strtolower() and strtoupper(), case folding is performed on the basis of the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as A-umlaut (Ä).

For more information about the Unicode properties, please see » http://www.unicode.org/unicode/reports/tr21/.

Changelog

Version Description
7.3.0 Added support for MB_CASE_FOLD, MB_CASE_UPPER_SIMPLE, MB_CASE_LOWER_SIMPLE, MB_CASE_TITLE_SIMPLE, and MB_CASE_FOLD_SIMPLE as mode.

Examples

Example #1 mb_convert_case() example

<?php
$str 
"mary had a Little lamb and she loved it so";
$str mb_convert_case($strMB_CASE_UPPER"UTF-8");
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
$str mb_convert_case($strMB_CASE_TITLE"UTF-8");
echo 
$str// Prints Mary Had A Little Lamb And She Loved It So
?>

Example #2 mb_convert_case() example with non-Latin UTF-8 text

<?php
$str 
"Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str mb_convert_case($strMB_CASE_UPPER"UTF-8");
echo 
$str// Prints ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
$str mb_convert_case($strMB_CASE_TITLE"UTF-8");
echo 
$str// Prints Τάχιστη Αλώπηξ Βαφήσ Ψημένη Γη, Δρασκελίζει Υπέρ Νωθρού Κυνόσ
?>

See Also



mb_convert_encoding

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_convert_encodingConvert character encoding

Description

mb_convert_encoding ( mixed $val , string $to_encoding [, mixed $from_encoding = mb_internal_encoding() ] ) : mixed

Converts the character encoding of val to to_encoding from optionally from_encoding. If val is an array, all its string values will be converted recursively.

Parameters

val

The string or array being encoded.

to_encoding

The type of encoding that val is being converted to.

from_encoding

Is specified by character code names before conversion. It is either an array, or a comma separated enumerated list. If from_encoding is not specified, the internal encoding will be used.

See supported encodings.

Return Values

The encoded string or array.

Examples

Example #1 mb_convert_encoding() example

<?php
/* Convert internal character encoding to SJIS */
$str mb_convert_encoding($str"SJIS");

/* Convert EUC-JP to UTF-7 */
$str mb_convert_encoding($str"UTF-7""EUC-JP");

/* Auto detect encoding from JIS, eucjp-win, sjis-win, then convert str to UCS-2LE */
$str mb_convert_encoding($str"UCS-2LE""JIS, eucjp-win, sjis-win");

/* "auto" is expanded to "ASCII,JIS,UTF-8,EUC-JP,SJIS" */
$str mb_convert_encoding($str"EUC-JP""auto");
?>

See Also

Changelog

Version Description
7.2.0 This function now also accepts an array as val. Formerly, only strings have been supported.


mb_convert_kana

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_convert_kanaConvert "kana" one from another ("zen-kaku", "han-kaku" and more)

Description

mb_convert_kana ( string $str [, string $option = "KV" [, string $encoding = mb_internal_encoding() ]] ) : string

Performs a "han-kaku" - "zen-kaku" conversion for string str. This function is only useful for Japanese.

Parameters

str

The string being converted.

option

The conversion option.

Specify with a combination of following options.
Applicable Conversion Options
Option Meaning
r Convert "zen-kaku" alphabets to "han-kaku"
R Convert "han-kaku" alphabets to "zen-kaku"
n Convert "zen-kaku" numbers to "han-kaku"
N Convert "han-kaku" numbers to "zen-kaku"
a Convert "zen-kaku" alphabets and numbers to "han-kaku"
A Convert "han-kaku" alphabets and numbers to "zen-kaku" (Characters included in "a", "A" options are U+0021 - U+007E excluding U+0022, U+0027, U+005C, U+007E)
s Convert "zen-kaku" space to "han-kaku" (U+3000 -> U+0020)
S Convert "han-kaku" space to "zen-kaku" (U+0020 -> U+3000)
k Convert "zen-kaku kata-kana" to "han-kaku kata-kana"
K Convert "han-kaku kata-kana" to "zen-kaku kata-kana"
h Convert "zen-kaku hira-gana" to "han-kaku kata-kana"
H Convert "han-kaku kata-kana" to "zen-kaku hira-gana"
c Convert "zen-kaku kata-kana" to "zen-kaku hira-gana"
C Convert "zen-kaku hira-gana" to "zen-kaku kata-kana"
V Collapse voiced sound notation and convert them into a character. Use with "K","H"

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

The converted string.

Examples

Example #1 mb_convert_kana() example

<?php
/* Convert all "kana" to "zen-kaku" "kata-kana" */
$str mb_convert_kana($str"KVC");

/* Convert "han-kaku" "kata-kana" to "zen-kaku" "kata-kana" 
   and "zen-kaku" alphanumeric to "han-kaku" */
$str mb_convert_kana($str"KVa");
?>



mb_convert_variables

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_convert_variablesConvert character code in variable(s)

Description

mb_convert_variables ( string $to_encoding , mixed $from_encoding , mixed &$vars [, mixed &$... ] ) : string

Converts character encoding of variables vars in encoding from_encoding to encoding to_encoding.

mb_convert_variables() join strings in Array or Object to detect encoding, since encoding detection tends to fail for short strings. Therefore, it is impossible to mix encoding in single array or object.

Parameters

to_encoding

The encoding that the string is being converted to.

from_encoding

from_encoding is specified as an array or comma separated string, it tries to detect encoding from from-coding. When from_encoding is omitted, detect_order is used.

vars

vars is the reference to the variable being converted. String, Array and Object are accepted. mb_convert_variables() assumes all parameters have the same encoding.

...

Additional vars.

Return Values

The character encoding before conversion for success, or FALSE for failure.

Examples

Example #1 mb_convert_variables() example

<?php
/* Convert variables $post1, $post2 to internal encoding */
$interenc mb_internal_encoding();
$inputenc mb_convert_variables($interenc"ASCII,UTF-8,SJIS-win"$post1$post2);
?>



mb_decode_mimeheader

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_decode_mimeheaderDecode string in MIME header field

Description

mb_decode_mimeheader ( string $str ) : string

Decodes encoded-word string str in MIME header.

Parameters

str

The string being decoded.

Return Values

The decoded string in internal character encoding.

See Also



mb_decode_numericentity

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_decode_numericentityDecode HTML numeric string reference to character

Description

mb_decode_numericentity ( string $str , array $convmap [, string $encoding = mb_internal_encoding() [, bool $is_hex = FALSE ]] ) : string

Convert numeric string reference of string str in a specified block to character.

Parameters

str

The string being decoded.

convmap

convmap is an array that specifies the code area to convert.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

is_hex

This parameter is not used.

Return Values

The converted string.

Changelog

Version Description
5.4.0 Added is_hex parameter.

Examples

Example #1 convmap example

<?php
$convmap 
= array (
   
int start_code1int end_code1int offset1int mask1,
   
int start_code2int end_code2int offset2int mask2,
   ........
   
int start_codeNint end_codeNint offsetNint maskN );
// Specify Unicode value for start_codeN and end_codeN
// Add offsetN to value and take bit-wise 'AND' with maskN, 
// then convert value to numeric string reference.
?>

Example #2 convmap example escapes JavaScript string

<?php
function escape_javascript_string($str) {
  
$map = [
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,0,0// 49
          
0,0,0,0,0,0,0,0,1,1,
          
1,1,1,1,1,0,0,0,0,0,
          
0,0,0,0,0,0,0,0,0,0,
          
0,0,0,0,0,0,0,0,0,0,
          
0,1,1,1,1,1,1,0,0,0// 99
          
0,0,0,0,0,0,0,0,0,0,
          
0,0,0,0,0,0,0,0,0,0,
          
0,0,0,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1// 149
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1// 199
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1,
          
1,1,1,1,1,1,1,1,1,1// 249
          
1,1,1,1,1,1,1// 255
          
];
  
// Char encoding is UTF-8
  
$mblen mb_strlen($str'UTF-8');
  
$utf32 bin2hex(mb_convert_encoding($str'UTF-32''UTF-8'));
  for (
$i=0$encoded=''$i $mblen$i++) {
      
$u substr($utf32$i*88);
      
$v base_convert($u1610);
      if (
$v 256 && $map[$v]) {
        
$encoded .= '\\x'.substr($u6,2);
      } else if (
$v == 2028) {
        
$encoded .= '\\u2028';
      } else if (
$v == 2029) {
        
$encoded .= '\\u2029';
      } else {
        
$encoded .= mb_convert_encoding(hex2bin($u), 'UTF-8''UTF-32');
      }
   }
   return 
$encoded;
}
 
// Test data
$convmap = [ 0x00xffff00xffff ];
$msg '';
for (
$i=0$i 1000$i++) {
  
// chr() cannot generate correct UTF-8 data larger value than 128, use mb_decode_numericentity().
  
$msg .= mb_decode_numericentity('&#'.$i.';'$convmap'UTF-8');
}
 
// var_dump($msg);
var_dump(escape_javascript_string($msg));

See Also



mb_detect_encoding

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_detect_encodingDetect character encoding

Description

mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = FALSE ]] ) : string

Detects character encoding in string str.

Parameters

str

The string being detected.

encoding_list

encoding_list is list of character encoding. Encoding order may be specified by array or comma separated list string.

If encoding_list is omitted, detect_order is used.

strict

strict specifies whether to use the strict encoding detection or not. Default is FALSE.

Return Values

The detected character encoding or FALSE if the encoding cannot be detected from the given string.

Examples

Example #1 mb_detect_encoding() example

<?php
/* Detect character encoding with current detect_order */
echo mb_detect_encoding($str);

/* "auto" is expanded according to mbstring.language */
echo mb_detect_encoding($str"auto");

/* Specify encoding_list character encoding by comma separated list */
echo mb_detect_encoding($str"JIS, eucjp-win, sjis-win");

/* Use array to specify encoding_list  */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
echo 
mb_detect_encoding($str$ary);
?>

See Also



mb_detect_order

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_detect_orderSet/Get character encoding detection order

Description

mb_detect_order ([ mixed $encoding_list = mb_detect_order() ] ) : mixed

Sets the automatic character encoding detection order to encoding_list.

Parameters

encoding_list

encoding_list is an array or comma separated list of character encoding. See supported encodings.

If encoding_list is omitted, it returns the current character encoding detection order as array.

This setting affects mb_detect_encoding() and mb_send_mail().

mbstring currently implements the following encoding detection filters. If there is an invalid byte sequence for the following encodings, encoding detection will fail.

UTF-8, UTF-7, ASCII, EUC-JP,SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP

For ISO-8859-*, mbstring always detects as ISO-8859-*.

For UTF-16, UTF-32, UCS2 and UCS4, encoding detection will fail always.

Return Values

When setting the encoding detection order, TRUE is returned on success or FALSE on failure.

When getting the encoding detection order, an ordered array of the encodings is returned.

Examples

Example #1 mb_detect_order() examples

<?php
/* Set detection order by enumerated list */
mb_detect_order("eucjp-win,sjis-win,UTF-8");

/* Set detection order by array */
$ary[] = "ASCII";
$ary[] = "JIS";
$ary[] = "EUC-JP";
mb_detect_order($ary);

/* Display current detection order */
echo implode(", "mb_detect_order());
?>

Example #2 Example showing useless detect orders

   ; Always detect as ISO-8859-1
   detect_order = ISO-8859-1, UTF-8
   
   ; Always detect as UTF-8, since ASCII/UTF-7 values are 
   ; valid for UTF-8
   detect_order = UTF-8, ASCII, UTF-7
   

See Also



mb_encode_mimeheader

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_encode_mimeheaderEncode string for MIME header

Description

mb_encode_mimeheader ( string $str [, string $charset = mb_language() [, string $transfer_encoding = "B" [, string $linefeed = "\r\n" [, int $indent = 0 ]]]] ) : string

Encodes a given string str by the MIME header encoding scheme.

Parameters

str

The string being encoded. Its encoding should be same as mb_internal_encoding().

charset

charset specifies the name of the character set in which str is represented in. The default value is determined by the current NLS setting (mbstring.language).

transfer_encoding

transfer_encoding specifies the scheme of MIME encoding. It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given.

linefeed

linefeed specifies the EOL (end-of-line) marker with which mb_encode_mimeheader() performs line-folding (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given.

indent

Indentation of the first line (number of characters in the header before str).

Return Values

A converted version of the string represented in ASCII.

Examples

Example #1 mb_encode_mimeheader() example

<?php
$name 
""// kanji
$mbox "kru";
$doma "gtinn.mon";
$addr mb_encode_mimeheader($name"UTF-7""Q") . " <" $mbox "@" $doma ">";
echo 
$addr;
?>

Notes

Note:

This function isn't designed to break lines at higher-level contextual break points (word boundaries, etc.). This behaviour may clutter up the original string with unexpected spaces.

See Also



mb_encode_numericentity

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_encode_numericentityEncode character to HTML numeric string reference

Description

mb_encode_numericentity ( string $str , array $convmap [, string $encoding = mb_internal_encoding() [, bool $is_hex = FALSE ]] ) : string

Converts specified character codes in string str from character code to HTML numeric character reference.

Parameters

str

The string being encoded.

convmap

convmap is array specifies code area to convert.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

is_hex

Whether the returned entity reference should be in hexadecimal notation (otherwise it is in decimal notation).

Return Values

The converted string.

Changelog

Version Description
5.4.0 Added is_hex parameter.

Examples

Example #1 convmap example

<?php
$convmap 
= array (
 
int start_code1int end_code1int offset1int mask1,
 
int start_code2int end_code2int offset2int mask2,
 ........
 
int start_codeNint end_codeNint offsetNint maskN );
// Specify Unicode value for start_codeN and end_codeN
// Add offsetN to value and take bit-wise 'AND' with maskN, then
// it converts value to numeric string reference.
?>

Examples

Example #2 mb_encode_numericentity() example

<?php
/* Convert Left side of ISO-8859-1 to HTML numeric character reference */
$convmap = array(0x800xff00xff);
$str mb_encode_numericentity($str$convmap"ISO-8859-1");

/* Convert user defined SJIS-win code in block 95-104 to numeric
   string reference */
$convmap = array(
       
0xe0000xe03e0x10400xffff,
       
0xe03f0xe0bb0x10410xffff,
       
0xe0bc0xe0fa0x10840xffff,
       
0xe0fb0xe1770x10850xffff,
       
0xe1780xe1b60x10c80xffff,
       
0xe1b70xe2330x10c90xffff,
       
0xe2340xe2720x110c0xffff,
       
0xe2730xe2ef0x110d0xffff,
       
0xe2f00xe32e0x11500xffff,
       
0xe32f0xe3ab0x11510xffff );
$str mb_encode_numericentity($str$convmap"sjis-win");
?>

See Also



mb_encoding_aliases

(PHP 5 >= 5.3.0, PHP 7)

mb_encoding_aliasesGet aliases of a known encoding type

Description

mb_encoding_aliases ( string $encoding ) : array

Returns an array of aliases for a known encoding type.

Parameters

encoding

The encoding type being checked, for aliases.

Return Values

Returns a numerically indexed array of encoding aliases on success, or FALSE on failure

Errors/Exceptions

Emits an E_WARNING level error if encoding is unknown.

Examples

Example #1 mb_encoding_aliases() example

<?php
$encoding        
'ASCII';
$known_encodings mb_list_encodings();

if (
in_array($encoding$known_encodings)) {

    
$aliases mb_encoding_aliases($encoding);
    
print_r($aliases);

} else {

    echo 
"Unknown ($encoding) encoding.\n";

}
?>

The above example will output something similar to:

   Array
   (
       [0] => ANSI_X3.4-1968
       [1] => iso-ir-6
       [2] => ANSI_X3.4-1986
       [3] => ISO_646.irv:1991
       [4] => US-ASCII
       [5] => ISO646-US
       [6] => us
       [7] => IBM367
       [8] => cp367
       [9] => csASCII
   )
   

See Also



mb_ereg_match

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_matchRegular expression match for multibyte string

Description

mb_ereg_match ( string $pattern , string $string [, string $option = "msr" ] ) : bool

A regular expression match for a multibyte string

Parameters

pattern

The regular expression pattern.

string

The string being evaluated.

option

The search option. See mb_regex_set_options() for explanation.

Return Values

Returns TRUE if string matches the regular expression pattern, FALSE if not.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_replace_callback

(PHP 5 >= 5.4.1, PHP 7)

mb_ereg_replace_callbackPerform a regular expression search and replace with multibyte support using a callback

Description

mb_ereg_replace_callback ( string $pattern , callable $callback , string $string [, string $option = "msr" ] ) : string

Scans string for matches to pattern, then replaces the matched text with the output of callback function.

The behavior of this function is almost identical to mb_ereg_replace(), except for the fact that instead of replacement parameter, one should specify a callback.

Parameters

pattern

The regular expression pattern.

Multibyte characters may be used in pattern.

callback

A callback that will be called and passed an array of matched elements in the subject string. The callback should return the replacement string.

You'll often need the callback function for a mb_ereg_replace_callback() in just one place. In this case you can use an anonymous function to declare the callback within the call to mb_ereg_replace_callback(). By doing it this way you have all information for the call in one place and do not clutter the function namespace with a callback function's name not used anywhere else.

string

The string being checked.

option

The search option. See mb_regex_set_options() for explanation.

Return Values

The resultant string on success, or FALSE on error.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

Examples

Example #1 mb_ereg_replace_callback() example

<?php
// this text was used in 2002
// we want to get this up to date for 2003
$text "April fools day is 04/01/2002\n";
$text.= "Last christmas was 12/24/2001\n";
// the callback function
function next_year($matches)
{
  
// as usual: $matches[0] is the complete match
  // $matches[1] the match for the first subpattern
  // enclosed in '(...)' and so on
  
return $matches[1].($matches[2]+1);
}
echo 
mb_ereg_replace_callback(
            
"(\d{2}/\d{2}/)(\d{4})",
            
"next_year",
            
$text);

?>

The above example will output:

   April fools day is 04/01/2003
   Last christmas was 12/24/2002
   

Example #2 mb_ereg_replace_callback() using anonymous function supported in PHP 5.3.0 or later

<?php
// this text was used in 2002
// we want to get this up to date for 2003
$text "April fools day is 04/01/2002\n";
$text.= "Last christmas was 12/24/2001\n";

echo 
mb_ereg_replace_callback(
            
"(\d{2}/\d{2}/)(\d{4})",
            function (
$matches) {
               return 
$matches[1].($matches[2]+1);
            },
            
$text);
?>

See Also



mb_ereg_replace

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_replaceReplace regular expression with multibyte support

Description

mb_ereg_replace ( string $pattern , string $replacement , string $string [, string $option = "msr" ] ) : string

Scans string for matches to pattern, then replaces the matched text with replacement

Parameters

pattern

The regular expression pattern.

Multibyte characters may be used in pattern.

replacement

The replacement text.

string

The string being checked.

option
The search option. See mb_regex_set_options() for explanation.

Return Values

The resultant string on success, or FALSE on error.

Changelog

Version Description
7.1.0 The e modifier has been deprecated.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

Warning

Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()). Not taking care of this will most likely create remote code execution vulnerabilities in your application.

See Also



mb_ereg_search_getpos

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_getposReturns start point for next regular expression match

Description

mb_ereg_search_getpos ( void ) : int

Returns the start point for the next regular expression match.

Parameters

This function has no parameters.

Return Values

mb_ereg_search_getpos() returns the point to start regular expression match for mb_ereg_search(), mb_ereg_search_pos(), mb_ereg_search_regs(). The position is represented by bytes from the head of string.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_search_getregs

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_getregsRetrieve the result from the last multibyte regular expression match

Description

mb_ereg_search_getregs ( void ) : array

Retrieve the result from the last multibyte regular expression match

Parameters

This function has no parameters.

Return Values

An array including the sub-string of matched part by last mb_ereg_search(), mb_ereg_search_pos(), mb_ereg_search_regs(). If there are some matches, the first element will have the matched sub-string, the second element will have the first part grouped with brackets, the third element will have the second part grouped with brackets, and so on. It returns FALSE on error;

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_search_init

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_initSetup string and regular expression for a multibyte regular expression match

Description

mb_ereg_search_init ( string $string [, string $pattern [, string $option = "msr" ]] ) : bool

mb_ereg_search_init() sets string and pattern for a multibyte regular expression. These values are used for mb_ereg_search(), mb_ereg_search_pos(), and mb_ereg_search_regs().

Parameters

string

The search string.

pattern

The search pattern.

option

The search option. See mb_regex_set_options() for explanation.

Return Values

Returns TRUE on success or FALSE on failure.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_search_pos

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_posReturns position and length of a matched part of the multibyte regular expression for a predefined multibyte string

Description

mb_ereg_search_pos ([ string $pattern [, string $option = "ms" ]] ) : array

Returns position and length of a matched part of the multibyte regular expression for a predefined multibyte string

The string for match is specified by mb_ereg_search_init(). If it is not specified, the previous one will be used.

Parameters

pattern

The search pattern.

option

The search option. See mb_regex_set_options() for explanation.

Return Values

An array containing two elements. The first element is the offset, in bytes, where the match begins relative to the start of the search string, and the second element is the length in bytes of the match.

If an error occurs, FALSE is returned.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_search_regs

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_regsReturns the matched part of a multibyte regular expression

Description

mb_ereg_search_regs ([ string $pattern [, string $option = "ms" ]] ) : array

Returns the matched part of a multibyte regular expression.

Parameters

pattern

The search pattern.

option

The search option. See mb_regex_set_options() for explanation.

Return Values

mb_ereg_search_regs() executes the multibyte regular expression match, and if there are some matched part, it returns an array including substring of matched part as first element, the first grouped part with brackets as second element, the second grouped part as third element, and so on. It returns FALSE on error.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_ereg_search_setpos

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_ereg_search_setposSet start point of next regular expression match

Description

mb_ereg_search_setpos ( int $position ) : bool

mb_ereg_search_setpos() sets the starting point of a match for mb_ereg_search().

Parameters

position

The position to set. If it is negative, it counts from the end of the string.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.1.0 Support for negative positions has been added.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also




mb_ereg

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_eregRegular expression match with multibyte support

Description

mb_ereg ( string $pattern , string $string [, array &$regs ] ) : int

Executes the regular expression match with multibyte support.

Parameters

pattern

The search pattern.

string

The search string.

regs

If matches are found for parenthesized substrings of pattern and the function is called with the third argument regs, the matches will be stored in the elements of the array regs. If no matches are found, regs is set to an empty array.

$regs[1] will contain the substring which starts at the first left parenthesis; $regs[2] will contain the substring starting at the second, and so on. $regs[0] will contain a copy of the complete string matched.

Return Values

Returns the byte length of the matched string if a match for pattern was found in string, or FALSE if no matches were found or an error occurred.

If the optional parameter regs was not passed or the length of the matched string is 0, this function returns 1.

Changelog

Version Description
7.1.0 mb_ereg() will now set regs to an empty array, if nothing matched. Formerly, regs was not modified in that case.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also

  • mb_regex_encoding() - Set/Get character encoding for multibyte regex
  • mb_eregi() - Regular expression match ignoring case with multibyte support



mb_eregi_replace

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_eregi_replaceReplace regular expression with multibyte support ignoring case

Description

mb_eregi_replace ( string $pattern , string $replace , string $string [, string $option = "msri" ] ) : string

Scans string for matches to pattern, then replaces the matched text with replacement.

Parameters

pattern

The regular expression pattern. Multibyte characters may be used. The case will be ignored.

replace

The replacement text.

string

The searched string.

option
The search option. See mb_regex_set_options() for explanation.

Return Values

The resultant string or FALSE on error.

Changelog

Version Description
7.1.0 The e modifier has been deprecated.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

Warning

Never use the e modifier when working on untrusted input. No automatic escaping will happen (as known from preg_replace()). Not taking care of this will most likely create remote code execution vulnerabilities in your application.

See Also



mb_eregi

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_eregiRegular expression match ignoring case with multibyte support

Description

mb_eregi ( string $pattern , string $string [, array &$regs ] ) : int

Executes the case insensitive regular expression match with multibyte support.

Parameters

pattern

The regular expression pattern.

string

The string being searched.

regs

If matches are found for parenthesized substrings of pattern and the function is called with the third argument regs, the matches will be stored in the elements of the array regs. If no matches are found, regs is set to an empty array.

$regs[1] will contain the substring which starts at the first left parenthesis; $regs[2] will contain the substring starting at the second, and so on. $regs[0] will contain a copy of the complete string matched.

Return Values

Returns the byte length of the matched string if a match for pattern was found in string, or FALSE if no matches were found or an error occurred.

If the optional parameter regs was not passed or the length of the matched string is 0, this function returns 1.

Changelog

Version Description
7.1.0 mb_eregi() will now set regs to an empty array, if nothing matched. Formerly, regs was not modified in that case.

Notes

Note:

The internal encoding or the character encoding specified by mb_regex_encoding() will be used as the character encoding for this function.

See Also



mb_get_info

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_get_infoGet internal settings of mbstring

Description

mb_get_info ([ string $type = "all" ] ) : mixed

mb_get_info() returns the internal setting parameters of mbstring.

Parameters

type

If type isn't specified or is specified to "all", an array having the elements "internal_encoding", "http_output", "http_input", "func_overload", "mail_charset", "mail_header_encoding", "mail_body_encoding" will be returned.

If type is specified as "http_output", "http_input", "internal_encoding", "func_overload", the specified setting parameter will be returned.

Return Values

An array of type information if type is not specified, otherwise a specific type.

Changelog

Version Description
5.3.0 The entry "http_output_conv_mimetypes" was made available.
5.1.3 The entries "mail_charset", "mail_header_encoding", and "mail_body_encoding" were made available.

See Also



mb_http_input

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_http_inputDetect HTTP input character encoding

Description

mb_http_input ([ string $type = "" ] ) : mixed

Detects the HTTP input character encoding.

Parameters

type

Input string specifies the input type. "G" for GET, "P" for POST, "C" for COOKIE, "S" for string, "L" for list, and "I" for the whole list (will return array). If type is omitted, it returns the last input type processed.

Return Values

The character encoding name, as per the type. If mb_http_input() does not process specified HTTP input, it returns FALSE.

See Also



mb_http_output

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_http_outputSet/Get HTTP output character encoding

Description

mb_http_output ([ string $encoding = mb_http_output() ] ) : mixed

Set/Get the HTTP output character encoding. Output after this function is called will be converted from the set internal encoding to encoding.

Parameters

encoding

If encoding is set, mb_http_output() sets the HTTP output character encoding to encoding.

If encoding is omitted, mb_http_output() returns the current HTTP output character encoding.

Return Values

If encoding is omitted, mb_http_output() returns the current HTTP output character encoding. Otherwise, Returns TRUE on success or FALSE on failure.

See Also



mb_internal_encoding

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_internal_encodingSet/Get internal character encoding

Description

mb_internal_encoding ([ string $encoding = mb_internal_encoding() ] ) : mixed

Set/Get the internal character encoding

Parameters

encoding

encoding is the character encoding name used for the HTTP input character encoding conversion, HTTP output character encoding conversion, and the default character encoding for string functions defined by the mbstring module. You should notice that the internal encoding is totally different from the one for multibyte regex.

Return Values

If encoding is set, then Returns TRUE on success or FALSE on failure. In this case, the character encoding for multibyte regex is NOT changed. If encoding is omitted, then the current character encoding name is returned.

Examples

Example #1 mb_internal_encoding() example

<?php
/* Set internal character encoding to UTF-8 */
mb_internal_encoding("UTF-8");

/* Display current internal character encoding */
echo mb_internal_encoding();
?>

See Also



mb_language

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_languageSet/Get current language

Description

mb_language ( string $language ) : bool
mb_language ( void ) : string

Set/Get the current language.

Parameters

language

Used for encoding e-mail messages. The valid languages are listed in the following table. mb_send_mail() uses this setting to encode e-mail.

Language Charset Encoding Notes
German/de ISO-8859-15 Quoted-Printable  
English/en ISO-8859-1 Quoted-Printable  
Armenian/hy ArmSCII-8 Quoted-Printable  
Japanese/ja ISO-2022-JP BASE64  
Korean/ko ISO-2022-KR BASE64  
neutral UTF-8 BASE64  
Russian/ru KOI8-R Quoted-Printable  
Turkish/tr ISO-8859-9 Quoted-Printable Available as of PHP 5.2.0
Ukrainian/ua KOI8-U Quoted-Printable Available as of PHP 5.3.0
uni UTF-8 BASE64  
Simplified Chinese/zh-cn HZ BASE64  
Traditional Chinese/zh-tw BIG-5 BASE64  

Return Values

If language is set and language is valid, it returns TRUE. Otherwise, it returns FALSE. When language is omitted, it returns the language name as a string.

See Also



mb_list_encodings

(PHP 5, PHP 7)

mb_list_encodingsReturns an array of all supported encodings

Description

mb_list_encodings ( void ) : array

Returns an array containing all supported encodings.

Parameters

This function has no parameters.

Return Values

Returns a numerically indexed array.

Errors/Exceptions

This function does not emit any errors.

Examples

Example #1 mb_list_encodings() example

<?php

print_r
(mb_list_encodings());

?>

The above example will output something similar to:

   Array
   (
       [0] => pass
       [1] => auto
       [2] => wchar
       [3] => byte2be
       [4] => byte2le
       [5] => byte4be
       [6] => byte4le
       [7] => BASE64
       [8] => UUENCODE
       [9] => HTML-ENTITIES
       [10] => Quoted-Printable
       [11] => 7bit
       [12] => 8bit
       [13] => UCS-4
       [14] => UCS-4BE
       [15] => UCS-4LE
       [16] => UCS-2
       [17] => UCS-2BE
       [18] => UCS-2LE
       [19] => UTF-32
       [20] => UTF-32BE
       [21] => UTF-32LE
       [22] => UTF-16
       [23] => UTF-16BE
       [24] => UTF-16LE
       [25] => UTF-8
       [26] => UTF-7
       [27] => UTF7-IMAP
       [28] => ASCII
       [29] => EUC-JP
       [30] => SJIS
       [31] => eucJP-win
       [32] => SJIS-win
       [33] => JIS
       [34] => ISO-2022-JP
       [35] => Windows-1252
       [36] => ISO-8859-1
       [37] => ISO-8859-2
       [38] => ISO-8859-3
       [39] => ISO-8859-4
       [40] => ISO-8859-5
       [41] => ISO-8859-6
       [42] => ISO-8859-7
       [43] => ISO-8859-8
       [44] => ISO-8859-9
       [45] => ISO-8859-10
       [46] => ISO-8859-13
       [47] => ISO-8859-14
       [48] => ISO-8859-15
       [49] => EUC-CN
       [50] => CP936
       [51] => HZ
       [52] => EUC-TW
       [53] => BIG-5
       [54] => EUC-KR
       [55] => UHC
       [56] => ISO-2022-KR
       [57] => Windows-1251
       [58] => CP866
       [59] => KOI8-R
   )
   



mb_ord

(PHP 7 >= 7.2.0)

mb_ordGet code point of character

Description

mb_ord ( string $str [, string $encoding ] ) : int

Warning

This function is currently not documented; only its argument list is available.

Parameters

str

encoding

Return Values

Returns a code point of character or FALSE on failure.

See Also

  • mb_chr() - Get a specific character
  • ord() - Convert the first byte of a string to a value between 0 and 255



mb_output_handler

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_output_handlerCallback function converts character encoding in output buffer

Description

mb_output_handler ( string $contents , int $status ) : string

mb_output_handler() is ob_start() callback function. mb_output_handler() converts characters in the output buffer from internal character encoding to HTTP output character encoding.

Parameters

contents

The contents of the output buffer.

status

The status of the output buffer.

Return Values

The converted string.

Examples

Example #1 mb_output_handler() example

<?php
mb_http_output
("UTF-8");
ob_start("mb_output_handler");
?>

Notes

Note:

If you want to output binary data, such as an image, a Content-Type: header must be set using header() before any binary data is sent to the client (e.g. header("Content-Type: image/png")). If Content-Type: header is sent, output character encoding conversion will not be performed.

Note that if 'Content-Type: text/*' is sent, the content body is regarded as text; conversion will take place.

See Also



mb_parse_str

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_parse_strParse GET/POST/COOKIE data and set global variable

Description

mb_parse_str ( string $encoded_string , array &$result ) : bool

Parses GET/POST/COOKIE data and sets global variables. Since PHP does not provide raw POST/COOKIE data, it can only be used for GET data for now. It parses URL encoded data, detects encoding, converts coding to internal encoding and set values to the result array or global variables.

Parameters

encoded_string

The URL encoded data.

result

An array containing decoded and character encoded converted values.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
8.0.0 The second parameter was no longer optional.
7.2.0 Calling mb_parse_str() without the second parameter was deprecated.

See Also



mb_preferred_mime_name

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_preferred_mime_nameGet MIME charset string

Description

mb_preferred_mime_name ( string $encoding ) : string

Get a MIME charset string for a specific encoding.

Parameters

encoding

The encoding being checked.

Return Values

The MIME charset string for character encoding encoding.

Examples

Example #1 mb_preferred_mime_name() example

<?php
$outputenc 
"sjis-win";
mb_http_output($outputenc);
ob_start("mb_output_handler");
header("Content-Type: text/html; charset=" mb_preferred_mime_name($outputenc));
?>



mb_regex_encoding

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_regex_encodingSet/Get character encoding for multibyte regex

Description

mb_regex_encoding ([ string $encoding = mb_regex_encoding() ] ) : mixed

Set/Get character encoding for a multibyte regex.

Parameters

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

If encoding is set, then Returns TRUE on success or FALSE on failure. In this case, the internal character encoding is NOT changed. If encoding is omitted, then the current character encoding name for a multibyte regex is returned.

Changelog

Version Description
5.6.0 Default encoding is changed to UTF-8. It was EUC-JP Previously.

See Also



mb_regex_set_options

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_regex_set_optionsSet/Get the default options for mbregex functions

Description

mb_regex_set_options ([ string $options = mb_regex_set_options() ] ) : string

Sets the default options described by options for multibyte regex functions.

Parameters

options

The options to set. This is a string where each character is an option. To set a mode, the mode character must be the last one set, however there can only be set one mode but multiple options.

Regex options
Option Meaning
i Ambiguity match on
x Enables extended pattern form
m '.' matches with newlines
s '^' -> '\A', '$' -> '\Z'
p Same as both the m and s options
l Finds longest matches
n Ignores empty matches
e eval() resulting code
Regex syntax modes
Mode Meaning
j Java (Sun java.util.regex)
u GNU regex
g grep
c Emacs
r Ruby
z Perl
b POSIX Basic regex
d POSIX Extended regex

Return Values

The string that describes the current options is returned.

See Also

  • mb_split() - Split multibyte string using regular expression
  • mb_ereg() - Regular expression match with multibyte support
  • mb_eregi() - Regular expression match ignoring case with multibyte support



mb_scrub

(PHP 7 >= 7.2.0)

mb_scrubDescription

Description

mb_scrub ( string $str [, string $encoding ] ) : string

Warning

This function is currently not documented; only its argument list is available.

Parameters

str

encoding

Return Values



mb_send_mail

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_send_mailSend encoded mail

Description

mb_send_mail ( string $to , string $subject , string $message [, mixed $additional_headers = NULL [, string $additional_parameter = NULL ]] ) : bool

Sends email. Headers and messages are converted and encoded according to the mb_language() setting. It's a wrapper function for mail(), so see also mail() for details.

Parameters

to

The mail addresses being sent to. Multiple recipients may be specified by putting a comma between each address in to. This parameter is not automatically encoded.

subject

The subject of the mail.

message

The message of the mail.

additional_headers (optional)

String or array to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). Validate parameter not to be injected unwanted headers by attackers.

If an array is passed, its keys are the header names and its values are the respective header values.

Note:

When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.

Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Note:

If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

additional_parameter

additional_parameter is a MTA command line parameter. It is useful when setting the correct Return-Path header when using sendmail.

This parameter is escaped by escapeshellcmd() internally to prevent command execution. escapeshellcmd() prevents command execution, but allows to add additional parameters. For security reason, this parameter should be validated.

Since escapeshellcmd() is applied automatically, some characters that are allowed as email addresses by internet RFCs cannot be used. Programs that are required to use these characters mail() cannot be used.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.2.0 The additional_headers parameter now also accepts an array.

See Also



mb_split

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

mb_splitSplit multibyte string using regular expression

Description

mb_split ( string $pattern , string $string [, int $limit = -1 ] ) : array

Split a multibyte string using regular expression pattern and returns the result as an array.

Parameters

pattern

The regular expression pattern.

string

The string being split.

limit
If optional parameter limit is specified, it will be split in limit elements as maximum.

Return Values

The result as an array, or FALSE on failure.

Notes

Note:

The character encoding specified by mb_regex_encoding() will be used as the character encoding for this function by default.

See Also



mb_str_split

(PHP 7 >= 7.4.0)

mb_str_splitGiven a multibyte string, return an array of its characters

Description

mb_str_split ( string $string [, int $split_length = 1 [, string $encoding = mb_internal_encoding() ]] ) : array

This function will return an array of strings, it is a version of str_split() with support for encodings of variable character size as well as fixed-size encodings of 1,2 or 4 byte characters. If the split_length parameter is specified, the string is broken down into chunks of the specified length in characters (not bytes). The encoding parameter can be optionally specified and it is good practice to do so.

Parameters

string

The string to split into characters or chunks.

split_length

If specified, each element of the returned array will be composed of multiple characters instead of a single character.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

A string specifying one of the supported encodings.

Return Values

mb_str_split() returns an array of strings, or FALSE on failure.

See Also



mb_strcut

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strcutGet part of string

Description

mb_strcut ( string $str , int $start [, int $length = NULL [, string $encoding = mb_internal_encoding() ]] ) : string

mb_strcut() extracts a substring from a string similarly to mb_substr(), but operates on bytes instead of characters. If the cut position happens to be between two bytes of a multi-byte character, the cut is performed starting from the first byte of that character. This is also the difference to the substr() function, which would simply cut the string between the bytes and thus result in a malformed byte sequence.

Parameters

str

The string being cut.

start

If start is non-negative, the returned string will start at the start'th byte position in str, counting from zero. For instance, in the string 'abcdef', the byte at position 0 is 'a', the byte at position 2 is 'c', and so forth.

If start is negative, the returned string will start at the start'th byte counting back from the end of str. However, if the magnitude of a negative start is greater than the length of the string, the returned portion will start from the beginning of str.

length

Length in bytes. If omitted or NULL is passed, extract all bytes to the end of the string.

If length is negative, the returned string will end at the length'th byte counting back from the end of str. However, if the magnitude of a negative length is greater than the number of characters after the start position, an empty string will be returned.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

mb_strcut() returns the portion of str specified by the start and length parameters.

Changelog

Version Description
5.4.8 Passing NULL as length extracts all bytes to the end of the string. Prior to this version NULL was treated the same as 0.

See Also



mb_strimwidth

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strimwidthGet truncated string with specified width

Description

mb_strimwidth ( string $str , int $start , int $width [, string $trimmarker = "" [, string $encoding = mb_internal_encoding() ]] ) : string

Truncates string str to specified width.

Parameters

str

The string being decoded.

start

The start position offset. Number of characters from the beginning of string (first character is 0), or if start is negative, number of characters from the end of the string.

width

The width of the desired trim. Negative widths count from the end of the string.

trimmarker

A string that is added to the end of string when string is truncated.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

The truncated string. If trimmarker is set, trimmarker replaces the last chars to match the width.

Changelog

Version Description
7.1.0 Support for negative starts and widths has been added.

Examples

Example #1 mb_strimwidth() example

<?php
echo mb_strimwidth("Hello World"010"...");
// output: "Hello W..."
?>

See Also



mb_stripos

(PHP 5 >= 5.2.0, PHP 7)

mb_striposFinds position of first occurrence of a string within another, case insensitive

Description

mb_stripos ( string $haystack , string $needle [, int $offset = 0 [, string $encoding = mb_internal_encoding() ]] ) : int

mb_stripos() returns the numeric position of the first occurrence of needle in the haystack string. Unlike mb_strpos(), mb_stripos() is case-insensitive. If needle is not found, it returns FALSE.

Parameters

haystack

The string from which to get the position of the first occurrence of needle

needle

The string to find in haystack

offset

The position in haystack to start searching. A negative offset counts from the end of the string.

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Return the numeric position of the first occurrence of needle in the haystack string, or FALSE if needle is not found.

Changelog

Version Description
7.1.0 Support for negative offsets has been added.

See Also

  • stripos() - Find the position of the first occurrence of a case-insensitive substring in a string
  • strpos() - Find the position of the first occurrence of a substring in a string
  • mb_strpos() - Find position of first occurrence of string in a string



mb_stristr

(PHP 5 >= 5.2.0, PHP 7)

mb_stristrFinds first occurrence of a string within another, case insensitive

Description

mb_stristr ( string $haystack , string $needle [, bool $before_needle = FALSE [, string $encoding = mb_internal_encoding() ]] ) : string

mb_stristr() finds the first occurrence of needle in haystack and returns the portion of haystack. Unlike mb_strstr(), mb_stristr() is case-insensitive. If needle is not found, it returns FALSE.

Parameters

haystack

The string from which to get the first occurrence of needle

needle

The string to find in haystack

before_needle

Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the first occurrence of needle (excluding needle). If set to FALSE, it returns all of haystack from the first occurrence of needle to the end (including needle).

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Returns the portion of haystack, or FALSE if needle is not found.

See Also

  • stristr() - Case-insensitive strstr
  • strstr() - Find the first occurrence of a string
  • mb_strstr() - Finds first occurrence of a string within another



mb_strlen

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strlenGet string length

Description

mb_strlen ( string $str [, string $encoding = mb_internal_encoding() ] ) : int

Gets the length of a string.

Parameters

str

The string being checked for length.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

Returns the number of characters in string str having character encoding encoding. A multi-byte character is counted as 1.

Errors/Exceptions

If the encoding is unknown, an error of level E_WARNING is generated.

See Also



mb_strpos

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strposFind position of first occurrence of string in a string

Description

mb_strpos ( string $haystack , string $needle [, int $offset = 0 [, string $encoding = mb_internal_encoding() ]] ) : int

Finds position of the first occurrence of a string in a string.

Performs a multi-byte safe strpos() operation based on number of characters. The first character's position is 0, the second character position is 1, and so on.

Parameters

haystack

The string being checked.

needle

The string to find in haystack. In contrast with strpos(), numeric values are not applied as the ordinal value of a character.

offset

The search offset. If it is not specified, 0 is used. A negative offset counts from the end of the string.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

Returns the numeric position of the first occurrence of needle in the haystack string. If needle is not found, it returns FALSE.

Changelog

Version Description
7.1.0 Support for negative offsets has been added.

See Also



mb_strrchr

(PHP 5 >= 5.2.0, PHP 7)

mb_strrchrFinds the last occurrence of a character in a string within another

Description

mb_strrchr ( string $haystack , string $needle [, bool $part = FALSE [, string $encoding = mb_internal_encoding() ]] ) : string

mb_strrchr() finds the last occurrence of needle in haystack and returns the portion of haystack. If needle is not found, it returns FALSE.

Parameters

haystack

The string from which to get the last occurrence of needle

needle

The string to find in haystack

part

Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the last occurrence of needle. If set to FALSE, it returns all of haystack from the last occurrence of needle to the end,

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Returns the portion of haystack. or FALSE if needle is not found.

See Also

  • strrchr() - Find the last occurrence of a character in a string
  • mb_strstr() - Finds first occurrence of a string within another
  • mb_strrichr() - Finds the last occurrence of a character in a string within another, case insensitive



mb_strrichr

(PHP 5 >= 5.2.0, PHP 7)

mb_strrichrFinds the last occurrence of a character in a string within another, case insensitive

Description

mb_strrichr ( string $haystack , string $needle [, bool $part = FALSE [, string $encoding = mb_internal_encoding() ]] ) : string

mb_strrichr() finds the last occurrence of needle in haystack and returns the portion of haystack. Unlike mb_strrchr(), mb_strrichr() is case-insensitive. If needle is not found, it returns FALSE.

Parameters

haystack

The string from which to get the last occurrence of needle

needle

The string to find in haystack

part

Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the last occurrence of needle. If set to FALSE, it returns all of haystack from the last occurrence of needle to the end,

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Returns the portion of haystack. or FALSE if needle is not found.

See Also

  • mb_stristr() - Finds first occurrence of a string within another, case insensitive
  • mb_strrchr() - Finds the last occurrence of a character in a string within another



mb_strripos

(PHP 5 >= 5.2.0, PHP 7)

mb_strriposFinds position of last occurrence of a string within another, case insensitive

Description

mb_strripos ( string $haystack , string $needle [, int $offset = 0 [, string $encoding = mb_internal_encoding() ]] ) : int

mb_strripos() performs multi-byte safe strripos() operation based on number of characters. needle position is counted from the beginning of haystack. First character's position is 0. Second character position is 1. Unlike mb_strrpos(), mb_strripos() is case-insensitive.

Parameters

haystack

The string from which to get the position of the last occurrence of needle

needle

The string to find in haystack

offset

The position in haystack to start searching

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Return the numeric position of the last occurrence of needle in the haystack string, or FALSE if needle is not found.

See Also

  • strripos() - Find the position of the last occurrence of a case-insensitive substring in a string
  • strrpos() - Find the position of the last occurrence of a substring in a string
  • mb_strrpos() - Find position of last occurrence of a string in a string



mb_strrpos

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strrposFind position of last occurrence of a string in a string

Description

mb_strrpos ( string $haystack , string $needle [, int $offset = 0 [, string $encoding = mb_internal_encoding() ]] ) : int

Performs a multibyte safe strrpos() operation based on the number of characters. needle position is counted from the beginning of haystack. First character's position is 0. Second character position is 1.

Parameters

haystack

The string being checked, for the last occurrence of needle

needle

The string to find in haystack.

offset
May be specified to begin searching an arbitrary number of characters into the string. Negative values will stop searching at an arbitrary point prior to the end of the string.
encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

Returns the numeric position of the last occurrence of needle in the haystack string. If needle is not found, it returns FALSE.

Changelog

Version Description
5.2.0 Added the optional parameter offset.

Notes

Note: The encoding parameter was moved from the third position to the fourth in PHP 5.2.0. For backward compatibility, encoding can be specified as the third parameter, but doing so is deprecated and will be removed in the future.

See Also

  • mb_strpos() - Find position of first occurrence of string in a string
  • mb_internal_encoding() - Set/Get internal character encoding
  • strrpos() - Find the position of the last occurrence of a substring in a string



mb_strstr

(PHP 5 >= 5.2.0, PHP 7)

mb_strstrFinds first occurrence of a string within another

Description

mb_strstr ( string $haystack , string $needle [, bool $before_needle = FALSE [, string $encoding = mb_internal_encoding() ]] ) : string

mb_strstr() finds the first occurrence of needle in haystack and returns the portion of haystack. If needle is not found, it returns FALSE.

Parameters

haystack

The string from which to get the first occurrence of needle

needle

The string to find in haystack

before_needle

Determines which portion of haystack this function returns. If set to TRUE, it returns all of haystack from the beginning to the first occurrence of needle (excluding needle). If set to FALSE, it returns all of haystack from the first occurrence of needle to the end (including needle).

encoding

Character encoding name to use. If it is omitted, internal character encoding is used.

Return Values

Returns the portion of haystack, or FALSE if needle is not found.

See Also

  • stristr() - Case-insensitive strstr
  • strstr() - Find the first occurrence of a string
  • mb_stristr() - Finds first occurrence of a string within another, case insensitive



mb_strtolower

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_strtolowerMake a string lowercase

Description

mb_strtolower ( string $str [, string $encoding = mb_internal_encoding() ] ) : string

Returns str with all alphabetic characters converted to lowercase.

Parameters

str

The string being lowercased.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

str with all alphabetic characters converted to lowercase.

Unicode

For more information about the Unicode properties, please see » http://www.unicode.org/unicode/reports/tr21/.

By contrast to strtolower(), 'alphabetic' is determined by the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as A-umlaut (Ä).

Examples

Example #1 mb_strtolower() example

<?php
$str 
"Mary Had A Little Lamb and She LOVED It So";
$str mb_strtolower($str);
echo 
$str// Prints mary had a little lamb and she loved it so
?>

Example #2 mb_strtolower() example with non-Latin UTF-8 text

<?php
$str 
"Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str mb_strtolower($str'UTF-8');
echo 
$str// Prints τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός
?>

See Also



mb_strtoupper

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_strtoupperMake a string uppercase

Description

mb_strtoupper ( string $str [, string $encoding = mb_internal_encoding() ] ) : string

Returns str with all alphabetic characters converted to uppercase.

Parameters

str

The string being uppercased.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

str with all alphabetic characters converted to uppercase.

Unicode

For more information about the Unicode properties, please see » http://www.unicode.org/unicode/reports/tr21/.

By contrast to strtoupper(), 'alphabetic' is determined by the Unicode character properties. Thus the behaviour of this function is not affected by locale settings and it can convert any characters that have 'alphabetic' property, such as a-umlaut (ä).

Examples

Example #1 mb_strtoupper() example

<?php
$str 
"Mary Had A Little Lamb and She LOVED It So";
$str mb_strtoupper($str);
echo 
$str// Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
?>

Example #2 mb_strtoupper() example with non-Latin UTF-8 text

<?php
$str 
"Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str mb_strtoupper($str'UTF-8');
echo 
$str// Prints ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
?>

See Also



mb_strwidth

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_strwidthReturn width of string

Description

mb_strwidth ( string $str [, string $encoding = mb_internal_encoding() ] ) : int

Returns the width of string str, where halfwidth characters count as 1, and fullwidth characters count as 2.

The fullwidth characters are: U+1100-U+115F, U+11A3-U+11A7, U+11FA-U+11FF, U+2329-U+232A, U+2E80-U+2E99, U+2E9B-U+2EF3, U+2F00-U+2FD5, U+2FF0-U+2FFB, U+3000-U+303E, U+3041-U+3096, U+3099-U+30FF, U+3105-U+312D, U+3131-U+318E, U+3190-U+31BA, U+31C0-U+31E3, U+31F0-U+321E, U+3220-U+3247, U+3250-U+32FE, U+3300-U+4DBF, U+4E00-U+A48C, U+A490-U+A4C6, U+A960-U+A97C, U+AC00-U+D7A3, U+D7B0-U+D7C6, U+D7CB-U+D7FB, U+F900-U+FAFF, U+FE10-U+FE19, U+FE30-U+FE52, U+FE54-U+FE66, U+FE68-U+FE6B, U+FF01-U+FF60, U+FFE0-U+FFE6, U+1B000-U+1B001, U+1F200-U+1F202, U+1F210-U+1F23A, U+1F240-U+1F248, U+1F250-U+1F251, U+20000-U+2FFFD, U+30000-U+3FFFD. All other characters are halfwidth characters.

Parameters

str

The string being decoded.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

The width of string str.

See Also



mb_substitute_character

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_substitute_characterSet/Get substitution character

Description

mb_substitute_character ([ mixed $substchar = mb_substitute_character() ] ) : mixed

Specifies a substitution character when input character encoding is invalid or character code does not exist in output character encoding. Invalid characters may be substituted NULL (no output), string or integer value (Unicode character code value).

This setting affects mb_convert_encoding(), mb_convert_variables(), mb_output_handler(), and mb_send_mail().

Parameters

substchar

Specify the Unicode value as an integer, or as one of the following strings:

  • "none": no output
  • "long": Output character code value (Example: U+3000, JIS+7E7E)
  • "entity": Output character entity (Example: &#x200;)

Return Values

If substchar is set, it returns TRUE for success, otherwise returns FALSE. If substchar is not set, it returns the current setting.

Examples

Example #1 mb_substitute_character() example

<?php
/* Set with Unicode U+3013 (GETA MARK) */
mb_substitute_character(0x3013);

/* Set hex format */
mb_substitute_character("long");

/* Display current setting */
echo mb_substitute_character();
?>



mb_substr_count

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_substr_countCount the number of substring occurrences

Description

mb_substr_count ( string $haystack , string $needle [, string $encoding = mb_internal_encoding() ] ) : int

Counts the number of times the needle substring occurs in the haystack string.

Parameters

haystack

The string being checked.

needle

The string being found.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

The number of times the needle substring occurs in the haystack string.

Examples

Example #1 mb_substr_count() example

<?php
echo mb_substr_count("This is a test""is"); // prints out 2
?>

See Also



mb_substr

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

mb_substrGet part of string

Description

mb_substr ( string $str , int $start [, int $length = NULL [, string $encoding = mb_internal_encoding() ]] ) : string

Performs a multi-byte safe substr() operation based on number of characters. Position is counted from the beginning of str. First character's position is 0. Second character position is 1, and so on.

Parameters

str

The string to extract the substring from.

start

If start is non-negative, the returned string will start at the start'th position in str, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.

If start is negative, the returned string will start at the start'th character from the end of str.

length

Maximum number of characters to use from str. If omitted or NULL is passed, extract all characters to the end of the string.

encoding

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Return Values

mb_substr() returns the portion of str specified by the start and length parameters.

Changelog

Version Description
5.4.8 Passing NULL as length extracts all characters to the end of the string. Prior to this version NULL was treated the same as 0.

See Also


Table of Contents




Pspell


Introduction

These functions allow you to check the spelling of a word and offer suggestions.



Installing/Configuring

Table of Contents


Requirements

To compile PHP with pspell support, you need the aspell library, available from » http://aspell.net/.



Installation

If you have the libraries needed add the --with-pspell[=dir] option when compiling PHP.

Note: Note to Win32 Users

In order for this extension to work, there are DLL files that must be available to the Windows system PATH. For information on how to do this, see the FAQ entitled "How do I add my PHP directory to the PATH on Windows". Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system's PATH), this is not recommended. This extension requires the following files to be in the PATH: aspell-15.dll from the bin folder of the aspell installation.

Win32 support requires at least aspell version 0.50.



Runtime Configuration

This extension has no configuration directives defined in php.ini.



Resource Types

This extension has no resource types defined.




Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

PSPELL_FAST (integer)
PSPELL_NORMAL (integer)
PSPELL_BAD_SPELLERS (integer)
PSPELL_RUN_TOGETHER (integer)


Pspell Functions


pspell_add_to_personal

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_add_to_personalAdd the word to a personal wordlist

Description

pspell_add_to_personal ( int $dictionary_link , string $word ) : bool

pspell_add_to_personal() adds a word to the personal wordlist. If you used pspell_new_config() with pspell_config_personal() to open the dictionary, you can save the wordlist later with pspell_save_wordlist().

Parameters

dictionary_link

word

The added word.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_add_to_personal()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
$pspell_link pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link"Vlad");
pspell_save_wordlist($pspell_link);
?>

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_add_to_session

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_add_to_sessionAdd the word to the wordlist in the current session

Description

pspell_add_to_session ( int $dictionary_link , string $word ) : bool

pspell_add_to_session() adds a word to the wordlist associated with the current session. It is very similar to pspell_add_to_personal()

Parameters

dictionary_link

word

The added word.

Return Values

Returns TRUE on success or FALSE on failure.



pspell_check

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_checkCheck a word

Description

pspell_check ( int $dictionary_link , string $word ) : bool

pspell_check() checks the spelling of a word.

Parameters

dictionary_link

word

The tested word.

Return Values

Returns TRUE if the spelling is correct, FALSE if not.

Examples

Example #1 pspell_check() Example

<?php
$pspell_link 
pspell_new("en");

if (
pspell_check($pspell_link"testt")) {
    echo 
"This is a valid spelling";
} else {
    echo 
"Sorry, wrong spelling";
}
?>



pspell_clear_session

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_clear_sessionClear the current session

Description

pspell_clear_session ( int $dictionary_link ) : bool

pspell_clear_session() clears the current session. The current wordlist becomes blank, and, for example, if you try to save it with pspell_save_wordlist(), nothing happens.

Parameters

dictionary_link

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_add_to_personal() Example

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
$pspell_link pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link"Vlad");
pspell_clear_session($pspell_link);
pspell_save_wordlist($pspell_link);    //"Vlad" will not be saved
?>



pspell_config_create

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_createCreate a config used to open a dictionary

Description

pspell_config_create ( string $language [, string $spelling [, string $jargon [, string $encoding ]]] ) : int

Create a config used to open a dictionary.

pspell_config_create() has a very similar syntax to pspell_new(). In fact, using pspell_config_create() immediately followed by pspell_new_config() will produce the exact same result. However, after creating a new config, you can also use pspell_config_*() functions before calling pspell_new_config() to take advantage of some advanced functionality.

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

Parameters

language

The language parameter is the language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling

The spelling parameter is the requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon

The jargon parameter contains extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding

The encoding parameter is the encoding that words are expected to be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. This parameter is largely untested, so be careful when using.

Return Values

Returns a pspell config identifier, or FALSE on error.

Examples

Example #1 pspell_config_create()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config"/var/dictionaries/custom.repl");
$pspell_link pspell_new_personal($pspell_config"en");
?>



pspell_config_data_dir

(PHP 5, PHP 7)

pspell_config_data_dirLocation of language data files

Description

pspell_config_data_dir ( int $conf , string $directory ) : bool

Warning

This function is currently not documented; only its argument list is available.

Return Values

Returns TRUE on success or FALSE on failure.



pspell_config_dict_dir

(PHP 5, PHP 7)

pspell_config_dict_dirLocation of the main word list

Description

pspell_config_dict_dir ( int $conf , string $directory ) : bool

Warning

This function is currently not documented; only its argument list is available.

Return Values

Returns TRUE on success or FALSE on failure.



pspell_config_ignore

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_ignoreIgnore words less than N characters long

Description

pspell_config_ignore ( int $dictionary_link , int $n ) : bool

pspell_config_ignore() should be used on a config before calling pspell_new_config(). This function allows short words to be skipped by the spell checker.

Parameters

dictionary_link

n

Words less than n characters will be skipped.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_config_ignore()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_ignore($pspell_config5);
$pspell_link pspell_new_config($pspell_config);
pspell_check($pspell_link"abcd");    //will not result in an error
?>



pspell_config_mode

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_modeChange the mode number of suggestions returned

Description

pspell_config_mode ( int $dictionary_link , int $mode ) : bool

pspell_config_mode() should be used on a config before calling pspell_new_config(). This function determines how many suggestions will be returned by pspell_suggest().

Parameters

dictionary_link

mode

The mode parameter is the mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_config_mode() Example

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_mode($pspell_configPSPELL_FAST);
$pspell_link pspell_new_config($pspell_config);
pspell_check($pspell_link"thecat");
?>



pspell_config_personal

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_personalSet a file that contains personal wordlist

Description

pspell_config_personal ( int $dictionary_link , string $file ) : bool

Set a file that contains personal wordlist. The personal wordlist will be loaded and used in addition to the standard one after you call pspell_new_config(). The file is also the file where pspell_save_wordlist() will save personal wordlist to.

pspell_config_personal() should be used on a config before calling pspell_new_config().

Parameters

dictionary_link

file

The personal wordlist. If the file does not exist, it will be created. The file should be writable by whoever PHP runs as (e.g. nobody).

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_config_personal()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
$pspell_link pspell_new_config($pspell_config);
pspell_check($pspell_link"thecat");
?>

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_config_repl

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_replSet a file that contains replacement pairs

Description

pspell_config_repl ( int $dictionary_link , string $file ) : bool

Set a file that contains replacement pairs.

The replacement pairs improve the quality of the spellchecker. When a word is misspelled, and a proper suggestion was not found in the list, pspell_store_replacement() can be used to store a replacement pair and then pspell_save_wordlist() to save the wordlist along with the replacement pairs.

pspell_config_repl() should be used on a config before calling pspell_new_config().

Parameters

dictionary_link

file

The file should be writable by whoever PHP runs as (e.g. nobody).

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_config_repl()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config"/var/dictionaries/custom.repl");
$pspell_link pspell_new_config($pspell_config);
pspell_check($pspell_link"thecat");
?>

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_config_runtogether

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_runtogetherConsider run-together words as valid compounds

Description

pspell_config_runtogether ( int $dictionary_link , bool $flag ) : bool

This function determines whether run-together words will be treated as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check(); pspell_suggest() will still return suggestions.

pspell_config_runtogether() should be used on a config before calling pspell_new_config().

Parameters

dictionary_link

flag

TRUE if run-together words should be treated as legal compounds, FALSE otherwise.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_config_runtogether()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_runtogether($pspell_configtrue);
$pspell_link pspell_new_config($pspell_config);
pspell_check($pspell_link"thecat");
?>



pspell_config_save_repl

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_config_save_replDetermine whether to save a replacement pairs list along with the wordlist

Description

pspell_config_save_repl ( int $dictionary_link , bool $flag ) : bool

pspell_config_save_repl() determines whether pspell_save_wordlist() will save the replacement pairs along with the wordlist. Usually there is no need to use this function because if pspell_config_repl() is used, the replacement pairs will be saved by pspell_save_wordlist() anyway, and if it is not, the replacement pairs will not be saved.

pspell_config_save_repl() should be used on a config before calling pspell_new_config().

Parameters

dictionary_link

flag

TRUE if replacement pairs should be saved, FALSE otherwise.

Return Values

Returns TRUE on success or FALSE on failure.

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_new_config

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_new_configLoad a new dictionary with settings based on a given config

Description

pspell_new_config ( int $config ) : int

pspell_new_config() opens up a new dictionary with settings specified in a config, created with pspell_config_create() and modified with pspell_config_*() functions. This method provides you with the most flexibility and has all the functionality provided by pspell_new() and pspell_new_personal().

Parameters

config

The config parameter is the one returned by pspell_config_create() when the config was created.

Return Values

Returns a dictionary link identifier on success, or FALSE on failure.

Examples

Example #1 pspell_new_config()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config"/var/dictionaries/custom.repl");
$pspell_link pspell_new_config($pspell_config);
?>



pspell_new_personal

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_new_personalLoad a new dictionary with personal wordlist

Description

pspell_new_personal ( string $personal , string $language [, string $spelling [, string $jargon [, string $encoding [, int $mode = 0 ]]]] ) : int

pspell_new_personal() opens up a new dictionary with a personal wordlist. The wordlist can be modified and saved with pspell_save_wordlist(), if desired. However, the replacement pairs are not saved. In order to save replacement pairs, you should create a config using pspell_config_create(), set the personal wordlist file with pspell_config_personal(), set the file for replacement pairs with pspell_config_repl(), and open a new dictionary with pspell_new_config().

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

Parameters

personal

The file where words added to the personal list will be stored. It should be an absolute filename beginning with '/' because otherwise it will be relative to $HOME, which is "/root" for most systems, and is probably not what you want.

language

The language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling

The requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon

Extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding

The encoding that words are expected to be in. Valid values are utf-8, iso8859-*, koi8-r, viscii, cp1252, machine unsigned 16, machine unsigned 32.

mode

The mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)
  • PSPELL_RUN_TOGETHER - Consider run-together words as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check(); pspell_suggest() will still return suggestions.
Mode is a bitmask constructed from different constants listed above. However, PSPELL_FAST, PSPELL_NORMAL and PSPELL_BAD_SPELLERS are mutually exclusive, so you should select only one of them.

Return Values

Returns the dictionary link identifier for use in other pspell functions.

Examples

Example #1 pspell_new_personal()

<?php
$pspell_link 
pspell_new_personal ("/var/dictionaries/custom.pws",
        
"en"""""""PSPELL_FAST|PSPELL_RUN_TOGETHER);
?>



pspell_new

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_newLoad a new dictionary

Description

pspell_new ( string $language [, string $spelling [, string $jargon [, string $encoding [, int $mode = 0 ]]]] ) : int

pspell_new() opens up a new dictionary and returns the dictionary link identifier for use in other pspell functions.

For more information and examples, check out inline manual pspell website:» http://aspell.net/.

Parameters

language

The language parameter is the language code which consists of the two letter ISO 639 language code and an optional two letter ISO 3166 country code after a dash or underscore.

spelling

The spelling parameter is the requested spelling for languages with more than one spelling such as English. Known values are 'american', 'british', and 'canadian'.

jargon

The jargon parameter contains extra information to distinguish two different words lists that have the same language and spelling parameters.

encoding

The encoding parameter is the encoding that words are expected to be in. Valid values are 'utf-8', 'iso8859-*', 'koi8-r', 'viscii', 'cp1252', 'machine unsigned 16', 'machine unsigned 32'. This parameter is largely untested, so be careful when using.

mode

The mode parameter is the mode in which spellchecker will work. There are several modes available:

  • PSPELL_FAST - Fast mode (least number of suggestions)
  • PSPELL_NORMAL - Normal mode (more suggestions)
  • PSPELL_BAD_SPELLERS - Slow mode (a lot of suggestions)
  • PSPELL_RUN_TOGETHER - Consider run-together words as legal compounds. That is, "thecat" will be a legal compound, although there should be a space between the two words. Changing this setting only affects the results returned by pspell_check(); pspell_suggest() will still return suggestions.
Mode is a bitmask constructed from different constants listed above. However, PSPELL_FAST, PSPELL_NORMAL and PSPELL_BAD_SPELLERS are mutually exclusive, so you should select only one of them.

Return Values

Returns the dictionary link identifier on success or FALSE on failure.

Examples

Example #1 pspell_new()

<?php
$pspell_link 
pspell_new("en""""""",
                           (
PSPELL_FAST|PSPELL_RUN_TOGETHER));
?>



pspell_save_wordlist

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_save_wordlistSave the personal wordlist to a file

Description

pspell_save_wordlist ( int $dictionary_link ) : bool

pspell_save_wordlist() saves the personal wordlist from the current session. The location of files to be saved specified with pspell_config_personal() and (optionally) pspell_config_repl().

Parameters

dictionary_link

A dictionary link identifier opened with pspell_new_personal().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_add_to_personal()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/tmp/dicts/newdict");
$pspell_link pspell_new_config($pspell_config);

pspell_add_to_personal($pspell_link"Vlad");
pspell_save_wordlist($pspell_link);
?>

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_store_replacement

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_store_replacementStore a replacement pair for a word

Description

pspell_store_replacement ( int $dictionary_link , string $misspelled , string $correct ) : bool

pspell_store_replacement() stores a replacement pair for a word, so that replacement can be returned by pspell_suggest() later. In order to be able to take advantage of this function, you have to use pspell_new_personal() to open the dictionary. In order to permanently save the replacement pair, you have to use pspell_config_personal() and pspell_config_repl() to set the path where to save your custom wordlists, and then use pspell_save_wordlist() for the changes to be written to disk.

Parameters

dictionary_link

A dictionary link identifier, opened with pspell_new_personal()

misspelled

The misspelled word.

correct

The fixed spelling for the misspelled word.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 pspell_store_replacement()

<?php
$pspell_config 
pspell_config_create("en");
pspell_config_personal($pspell_config"/var/dictionaries/custom.pws");
pspell_config_repl($pspell_config"/var/dictionaries/custom.repl");
$pspell_link pspell_new_config($pspell_config);

pspell_store_replacement($pspell_link$misspelled$correct);
pspell_save_wordlist($pspell_link);
?>

Notes

Note:

This function will not work unless you have pspell .11.2 and aspell .32.5 or later.



pspell_suggest

(PHP 4 >= 4.0.2, PHP 5, PHP 7)

pspell_suggestSuggest spellings of a word

Description

pspell_suggest ( int $dictionary_link , string $word ) : array

pspell_suggest() returns an array of possible spellings for the given word.

Parameters

dictionary_link

word

The tested word.

Return Values

Returns an array of possible spellings.

Examples

Example #1 pspell_suggest() example

<?php
$pspell_link 
pspell_new("en");

if (!
pspell_check($pspell_link"testt")) {
    
$suggestions pspell_suggest($pspell_link"testt");

    foreach (
$suggestions as $suggestion) {
        echo 
"Possible spelling: $suggestion<br />";
    }
}
?>


Table of Contents




GNU Recode


Introduction

This module contains an interface to the GNU Recode library. The GNU Recode library converts files between various coded character sets and surface encodings. When this cannot be achieved exactly, it may get rid of the offending characters or fall back on approximations. The library recognises or produces nearly 150 different character sets and is able to convert files between almost any pair. Most » RFC 1345 character sets are supported.

Note: This extension is unbundled and moved to » PECL as of PHP 7.4.0. Consider to use the Multibyte String or iconv extensions instead.

Note: This extension is not available on Windows platforms.



Installing/Configuring

Table of Contents


Requirements

You must have GNU Recode 3.5 or higher installed on your system. You can download the package from » http://directory.fsf.org/All_GNU_Packages/recode.html.

Warning

The Recode library version 3.6 adds weird characters behind converted strings under certain circumstances. Thus it's safer to use Recode v3.5 or one of the available alternatives like the iconv or mbstring extension.



Installation

PHP 7.4

This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 7.4.0

Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/recode.

PHP < 7.4

To be able to use the functions defined in this module you must compile your PHP interpreter using the --with-recode[=DIR] option.

Warning

Crashes and startup problems of PHP may be encountered when loading the recode as extension after loading any extension of mysql or imap. Loading the recode before those extension has proved to fix the problem. This is due a technical problem that both the c-client library used by imap and recode have their own hash_lookup() function and both mysql and recode have their own hash_insert function.

Warning

The IMAP, recode, YAZ and Cyrus extensions cannot be used in conjunction, because they share the same internal symbols. Note: Yaz 2.0 and above does not suffer from this problem.



Runtime Configuration

This extension has no configuration directives defined in php.ini.



Resource Types

This extension has no resource types defined.




Predefined Constants

This extension has no constants defined.



Recode Functions


recode_file

(PHP 4, PHP 5, PHP 7 < 7.4.0)

recode_fileRecode from file to file according to recode request

Description

recode_file ( string $request , resource $input , resource $output ) : bool

Recode the file referenced by file handle input into the file referenced by file handle output according to the recode request.

Parameters

request

The desired recode request type

input

A local file handle resource for the input

output

A local file handle resource for the output

Return Values

Returns FALSE, if unable to comply, TRUE otherwise.

Examples

Example #1 Basic recode_file() example

<?php
$input 
fopen('input.txt''r');
$output fopen('output.txt''w');
recode_file("us..flat"$input$output);
?>

Notes

This function does not currently process file handles referencing remote files (URLs). Both file handles must refer to local files.

See Also



recode_string

(PHP 4, PHP 5, PHP 7 < 7.4.0)

recode_stringRecode a string according to a recode request

Description

recode_string ( string $request , string $string ) : string

Recode the string string according to the recode request request.

Parameters

request

The desired recode request type

string

The string to be recoded

Return Values

Returns the recoded string or FALSE, if unable to perform the recode request.

Examples

Example #1 Basic recode_string() example

<?php
echo recode_string("us..flat""The following character has a diacritical mark: á");
?>

Notes

A simple recode request may be "lat1..iso646-de".

See Also

  • The GNU Recode documentation of your installation for detailed instructions about recode requests.



recode

(PHP 4, PHP 5, PHP 7 < 7.4.0)

recodeAlias of recode_string()

Description

This function is an alias of: recode_string().


Table of Contents





Image Processing and Generation


Cairo


Introduction

Cairo is a native PHP extension to create and modify graphics using the Cairo Graphics Library.

The Cairo Graphics Library is a 2D library written in C with support for multiple output devices. Currently supported output targets include the X Window System, Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL (through glitz), XCB, BeOS, OS/2, and DirectFB. The library also has support for two types of text manipulation and layout. The "toy" API provides demo quality support, and the glyphs API, although full-featured, works best with a helper library such as pango. Font backend support includes FreeType, Quartz, Win32, and User fonts.

There are two types of computer graphics, vector and raster. Raster graphics are the representation of images as an array of pixels. Vector graphics use geometrical primitives such as points, lines, curves or polygons to represent images. The primitives are created using mathematical equations. The Cairo Graphics Library takes a vector approach to graphics, allowing smaller size, infinite zooming, and moving, scaling and rotating without degrading image quality.

Operations in the cairo graphics library including stroking and filling cubic Bézier splines, transforming and compositing translucent images, and antialiased text rendering. All drawing operations can be transformed by any affine transformation (scale, rotation, shear, and others) This is very similar to drawing operations for PostScript and PDF drawing.

The Cairo PHP Extension aims to provide support for all officially supported font backends and surface backends, as well as expose all available functionality in cairo to PHP users.



Installing/Configuring

Table of Contents


Requirements

Cairo is only available for PHP 5.2+ and PHP 5.3+ The extension also requires the cairo graphics library version 1.4 or higher. The cairo graphics library uses an even and odd numbering scheme to denote stable and unstable library versions. Both unstable and stable versions can be used with the extension, but conditional support for new features is determined by the stable version below the unstable version in use. The latest cairo release can be found at » http://cairographics.org/.

The binary files used for the windows compiles can be found at » http://cairographics.org/download/ along with the project files used to create them.



Installation

Information for installing this PECL extension may be found in the manual chapter titled Installation of PECL extensions. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: » https://pecl.php.net/package/cairo.

A DLL for this PECL extension is currently unavailable. See also the building on Windows section.

Notes specific to installation on Windows

Binary builds of the extension can be found at » http://cairographics.org/download/. Download the correct zip file, place php_cairo.dll in the extensions directory, and enable it via the php.ini file in use. Please be sure the PHP minor version (5.2, 5.3) match, the thread safety (Thread Safe TS or Non-Thread Safe NTS), the architecture (x86 or x64), and the compiler version (VC6 or VC9) match or the extension will not load.



Runtime Configuration

This extension has no configuration directives defined in php.ini.



Resource Types

This extension has no resource types defined.




Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

CAIRO_STATUS_SUCCESS (integer)
CAIRO_STATUS_NO_MEMORY (integer)
CAIRO_STATUS_INVALID_RESTORE (integer)
CAIRO_STATUS_INVALID_POP_GROUP (integer)
CAIRO_STATUS_NO_CURRENT_POINT (integer)
CAIRO_STATUS_INVALID_MATRIX (integer)
CAIRO_STATUS_INVALID_STATUS (integer)
CAIRO_STATUS_NULL_POINTER (integer)
CAIRO_STATUS_INVALID_STRING (integer)
CAIRO_STATUS_INVALID_PATH_DATA (integer)
CAIRO_STATUS_READ_ERROR (integer)
CAIRO_STATUS_WRITE_ERROR (integer)
CAIRO_STATUS_SURFACE_FINISHED (integer)
CAIRO_STATUS_SURFACE_TYPE_MISMATCH (integer)
CAIRO_STATUS_PATTERN_TYPE_MISMATCH (integer)
CAIRO_STATUS_INVALID_CONTENT (integer)
CAIRO_STATUS_INVALID_FORMAT (integer)
CAIRO_STATUS_INVALID_VISUAL (integer)
CAIRO_STATUS_FILE_NOT_FOUND (integer)
CAIRO_STATUS_INVALID_DASH (integer)
CAIRO_STATUS_INVALID_DSC_COMMENT (integer)
CAIRO_STATUS_INVALID_INDEX (integer)
CAIRO_STATUS_CLIP_NOT_REPRESENTABLE (integer)
CAIRO_STATUS_TEMP_FILE_ERROR (integer)
CAIRO_STATUS_INVALID_STRIDE (integer)
CAIRO_ANTIALIAS_DEFAULT (integer)
CAIRO_ANTIALIAS_NONE (integer)
CAIRO_ANTIALIAS_GRAY (integer)
CAIRO_ANTIALIAS_SUBPIXEL (integer)
CAIRO_SUBPIXEL_ORDER_DEFAULT (integer)
CAIRO_SUBPIXEL_ORDER_RGB (integer)
CAIRO_SUBPIXEL_ORDER_BGR (integer)
CAIRO_SUBPIXEL_ORDER_VRGB (integer)
CAIRO_SUBPIXEL_ORDER_VBGR (integer)
CAIRO_FILL_RULE_WINDING (integer)
CAIRO_FILL_RULE_EVEN_ODD (integer)
CAIRO_LINE_CAP_BUTT (integer)
CAIRO_LINE_CAP_ROUND (integer)
CAIRO_LINE_CAP_SQUARE (integer)
CAIRO_LINE_JOIN_MITER (integer)
CAIRO_LINE_JOIN_ROUND (integer)
CAIRO_LINE_JOIN_BEVEL (integer)
CAIRO_OPERATOR_CLEAR (integer)
CAIRO_OPERATOR_SOURCE (integer)
CAIRO_OPERATOR_OVER (integer)
CAIRO_OPERATOR_IN (integer)
CAIRO_OPERATOR_OUT (integer)
CAIRO_OPERATOR_ATOP (integer)
CAIRO_OPERATOR_DEST (integer)
CAIRO_OPERATOR_DEST_OVER (integer)
CAIRO_OPERATOR_DEST_IN (integer)
CAIRO_OPERATOR_DEST_OUT (integer)
CAIRO_OPERATOR_DEST_ATOP (integer)
CAIRO_OPERATOR_XOR (integer)
CAIRO_OPERATOR_ADD (integer)
CAIRO_OPERATOR_SATURATE (integer)
CAIRO_PATTERN_TYPE_SOLID (integer)
CAIRO_PATTERN_TYPE_SURFACE (integer)
CAIRO_PATTERN_TYPE_LINEAR (integer)
CAIRO_PATTERN_TYPE_RADIAL (integer)
CAIRO_EXTEND_NONE (integer)
CAIRO_EXTEND_REPEAT (integer)
CAIRO_EXTEND_REFLECT (integer)
CAIRO_EXTEND_PAD (integer)
CAIRO_FILTER_FAST (integer)
CAIRO_FILTER_GOOD (integer)
CAIRO_FILTER_BEST (integer)
CAIRO_FILTER_NEAREST (integer)
CAIRO_FILTER_BILINEAR (integer)
CAIRO_FILTER_GAUSSIAN (integer)
CAIRO_HINT_STYLE_DEFAULT (integer)
CAIRO_HINT_STYLE_NONE (integer)
CAIRO_HINT_STYLE_SLIGHT (integer)
CAIRO_HINT_STYLE_MEDIUM (integer)
CAIRO_HINT_STYLE_FULL (integer)
CAIRO_HINT_METRICS_DEFAULT (integer)
CAIRO_HINT_METRICS_OFF (integer)
CAIRO_HINT_METRICS_ON (integer)
CAIRO_FONT_TYPE_TOY (integer)
CAIRO_FONT_TYPE_FT (integer)
CAIRO_FONT_TYPE_WIN32 (integer)
CAIRO_FONT_TYPE_QUARTZ (integer)
CAIRO_FONT_SLANT_NORMAL (integer)
CAIRO_FONT_SLANT_ITALIC (integer)
CAIRO_FONT_SLANT_OBLIQUE (integer)
CAIRO_FONT_WEIGHT_NORMAL (integer)
CAIRO_FONT_WEIGHT_BOLD (integer)
CAIRO_CONTENT_COLOR (integer)
CAIRO_CONTENT_ALPHA (integer)
CAIRO_CONTENT_COLOR_ALPHA (integer)
CAIRO_SURFACE_TYPE_IMAGE (integer)
CAIRO_SURFACE_TYPE_PDF (integer)
CAIRO_SURFACE_TYPE_PS (integer)
CAIRO_SURFACE_TYPE_XLIB (integer)
CAIRO_SURFACE_TYPE_XCB (integer)
CAIRO_SURFACE_TYPE_GLITZ (integer)
CAIRO_SURFACE_TYPE_QUARTZ (integer)
CAIRO_SURFACE_TYPE_WIN32 (integer)
CAIRO_SURFACE_TYPE_BEOS (integer)
CAIRO_SURFACE_TYPE_DIRECTFB (integer)
CAIRO_SURFACE_TYPE_SVG (integer)
CAIRO_SURFACE_TYPE_OS2 (integer)
CAIRO_SURFACE_TYPE_WIN32_PRINTING (integer)
CAIRO_SURFACE_TYPE_QUARTZ_IMAGE (integer)
CAIRO_FORMAT_ARGB32 (integer)
CAIRO_FORMAT_RGB24 (integer)
CAIRO_FORMAT_A8 (integer)
CAIRO_FORMAT_A1 (integer)
CAIRO_PS_LEVEL_2 (integer)
CAIRO_PS_LEVEL_3 (integer)
CAIRO_SVG_VERSION_1_1 (integer)
CAIRO_SVG_VERSION_1_2 (integer)



Examples

Description here...

Example #1 Cairo Example

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   


Cairo Functions


cairo_create

(PECL cairo >= 0.1.0)

cairo_createReturns a new CairoContext object on the requested surface

Description

cairo_create ( CairoSurface $surface ) : CairoContext

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_create

(PECL cairo >= 0.1.0)

cairo_font_options_createDescription

Description

cairo_font_options_create ( void ) : CairoFontOptions

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_equal

(PECL cairo >= 0.1.0)

cairo_font_options_equalDescription

Description

cairo_font_options_equal ( CairoFontOptions $options , CairoFontOptions $other ) : bool

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

other

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_equal() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_get_antialias

(PECL cairo >= 0.1.0)

cairo_font_options_get_antialiasDescription

Description

cairo_font_options_get_antialias ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_get_antialias() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_get_hint_metrics

(PECL cairo >= 0.1.0)

cairo_font_options_get_hint_metricsDescription

Description

cairo_font_options_get_hint_metrics ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_get_hint_metrics() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_get_hint_style

(PECL cairo >= 0.1.0)

cairo_font_options_get_hint_styleDescription

Description

cairo_font_options_get_hint_style ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_get_hint_style() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_get_subpixel_order

(PECL cairo >= 0.1.0)

cairo_font_options_get_subpixel_orderDescription

Description

cairo_font_options_get_subpixel_order ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_get_subpixel_order() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_hash

(PECL cairo >= 0.1.0)

cairo_font_options_hashDescription

Description

cairo_font_options_hash ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_hash() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_merge

(PECL cairo >= 0.1.0)

cairo_font_options_mergeDescription

Description

cairo_font_options_merge ( CairoFontOptions $options , CairoFontOptions $other ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

other

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_merge() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_set_antialias

(PECL cairo >= 0.1.0)

cairo_font_options_set_antialiasDescription

Description

cairo_font_options_set_antialias ( CairoFontOptions $options , int $antialias ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

antialias

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_set_antialias() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_set_hint_metrics

(PECL cairo >= 0.1.0)

cairo_font_options_set_hint_metricsDescription

Description

cairo_font_options_set_hint_metrics ( CairoFontOptions $options , int $hint_metrics ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

hint_metrics

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_set_hint_metrics() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_set_hint_style

(PECL cairo >= 0.1.0)

cairo_font_options_set_hint_styleDescription

Description

cairo_font_options_set_hint_style ( CairoFontOptions $options , int $hint_style ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

hint_style

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_set_hint_style() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_set_subpixel_order

(PECL cairo >= 0.1.0)

cairo_font_options_set_subpixel_orderDescription

Description

cairo_font_options_set_subpixel_order ( CairoFontOptions $options , int $subpixel_order ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

subpixel_order

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_set_subpixel_order() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_font_options_status

(PECL cairo >= 0.1.0)

cairo_font_options_statusDescription

Description

cairo_font_options_status ( CairoFontOptions $options ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

options

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_font_options_status() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_format_stride_for_width

(PECL cairo >= 0.1.0)

cairo_format_stride_for_widthDescription

Description

cairo_format_stride_for_width ( int $format , int $width ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

format

Description...

width

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_format_stride_for_width() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_create_for_data

(PECL cairo >= 0.1.0)

cairo_image_surface_create_for_dataDescription

Description

cairo_image_surface_create_for_data ( string $data , int $format , int $width , int $height [, int $stride = -1 ] ) : CairoImageSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

data

Description...

format

Description...

width

Description...

height

Description...

stride

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_create_for_data() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_create_from_png

(PECL cairo >= 0.1.0)

cairo_image_surface_create_from_pngDescription

Description

cairo_image_surface_create_from_png ( mixed $file ) : CairoImageSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_create_from_png() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_create

(PECL cairo >= 0.1.0)

cairo_image_surface_createDescription

Description

cairo_image_surface_create ( int $format , int $width , int $height ) : CairoImageSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

format

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_get_data

(PECL cairo >= 0.1.0)

cairo_image_surface_get_dataDescription

Description

cairo_image_surface_get_data ( CairoImageSurface $surface ) : string

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_get_data() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_get_format

(PECL cairo >= 0.1.0)

cairo_image_surface_get_formatDescription

Description

cairo_image_surface_get_format ( CairoImageSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_get_format() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_get_height

(PECL cairo >= 0.1.0)

cairo_image_surface_get_heightDescription

Description

cairo_image_surface_get_height ( CairoImageSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_get_height() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_get_stride

(PECL cairo >= 0.1.0)

cairo_image_surface_get_strideDescription

Description

cairo_image_surface_get_stride ( CairoImageSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_get_stride() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_image_surface_get_width

(PECL cairo >= 0.1.0)

cairo_image_surface_get_widthDescription

Description

cairo_image_surface_get_width ( CairoImageSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_image_surface_get_width() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_matrix_create_scale

(PECL cairo >= 0.1.0)

cairo_matrix_create_scaleAlias of CairoMatrix::initScale()

Description

This function is an alias of: CairoMatrix::initScale().

This function alias is deprecated and only exists for backwards compatibility reasons. The use of this function is not recommended, as it may be removed from PHP in the future.



cairo_matrix_create_translate

(PECL cairo >= 0.1.0)

cairo_matrix_create_translateAlias of CairoMatrix::initTranslate()

Description

This function is an alias of: CairoMatrix::initTranslate().

This function alias is deprecated and only exists for backwards compatibility reasons. The use of this function is not recommended, as it may be removed from PHP in the future.



cairo_matrix_invert

(PECL cairo >= 0.1.0)

cairo_matrix_invertDescription

Description

cairo_matrix_invert ( CairoMatrix $matrix ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_matrix_invert() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_matrix_multiply

(PECL cairo >= 0.1.0)

cairo_matrix_multiplyDescription

Description

cairo_matrix_multiply ( CairoMatrix $matrix1 , CairoMatrix $matrix2 ) : CairoMatrix

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix1

Description...

matrix2

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_matrix_multiply() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_matrix_transform_distance

(PECL cairo >= 0.1.0)

cairo_matrix_transform_distanceDescription

Description

cairo_matrix_transform_distance ( CairoMatrix $matrix , float $dx , float $dy ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix

Description...

dx

Description...

dy

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_matrix_transform_distance() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_matrix_transform_point

(PECL cairo >= 0.1.0)

cairo_matrix_transform_pointDescription

Description

cairo_matrix_transform_point ( CairoMatrix $matrix , float $dx , float $dy ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix

Description...

dx

Description...

dy

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_matrix_transform_point() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_matrix_translate

(PECL cairo >= 0.1.0)

cairo_matrix_translateDescription

Description

cairo_matrix_translate ( CairoMatrix $matrix , float $tx , float $ty ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix

Description...

tx

Description...

ty

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_matrix_translate() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_add_color_stop_rgb

(PECL cairo >= 0.1.0)

cairo_pattern_add_color_stop_rgbDescription

Description

cairo_pattern_add_color_stop_rgb ( CairoGradientPattern $pattern , float $offset , float $red , float $green , float $blue ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

offset

Description...

red

Description...

green

Description...

blue

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_add_color_stop_rgb() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_add_color_stop_rgba

(PECL cairo >= 0.1.0)

cairo_pattern_add_color_stop_rgbaDescription

Description

cairo_pattern_add_color_stop_rgba ( CairoGradientPattern $pattern , float $offset , float $red , float $green , float $blue , float $alpha ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

offset

Description...

red

Description...

green

Description...

blue

Description...

alpha

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_add_color_stop_rgba() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_create_for_surface

(PECL cairo >= 0.1.0)

cairo_pattern_create_for_surfaceDescription

Description

cairo_pattern_create_for_surface ( CairoSurface $surface ) : CairoPattern

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_create_for_surface() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_create_linear

(PECL cairo >= 0.1.0)

cairo_pattern_create_linearDescription

Description

cairo_pattern_create_linear ( float $x0 , float $y0 , float $x1 , float $y1 ) : CairoPattern

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x0

Description...

y0

Description...

x1

Description...

y1

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_create_linear() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_create_radial

(PECL cairo >= 0.1.0)

cairo_pattern_create_radialDescription

Description

cairo_pattern_create_radial ( float $x0 , float $y0 , float $r0 , float $x1 , float $y1 , float $r1 ) : CairoPattern

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x0

Description...

y0

Description...

r0

Description...

x1

Description...

y1

Description...

r1

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_create_radial() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_create_rgb

(PECL cairo >= 0.1.0)

cairo_pattern_create_rgbDescription

Description

cairo_pattern_create_rgb ( float $red , float $green , float $blue ) : CairoPattern

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

red

Description...

green

Description...

blue

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_create_rgb() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_create_rgba

(PECL cairo >= 0.1.0)

cairo_pattern_create_rgbaDescription

Description

cairo_pattern_create_rgba ( float $red , float $green , float $blue , float $alpha ) : CairoPattern

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

red

Description...

green

Description...

blue

Description...

alpha

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_create_rgba() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_color_stop_count

(PECL cairo >= 0.1.0)

cairo_pattern_get_color_stop_countDescription

Description

cairo_pattern_get_color_stop_count ( CairoGradientPattern $pattern ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_color_stop_count() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_color_stop_rgba

(PECL cairo >= 0.1.0)

cairo_pattern_get_color_stop_rgbaDescription

Description

cairo_pattern_get_color_stop_rgba ( CairoGradientPattern $pattern , int $index ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

index

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_color_stop_rgba() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_extend

(PECL cairo >= 0.1.0)

cairo_pattern_get_extendDescription

Description

cairo_pattern_get_extend ( string $pattern ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_extend() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_filter

(PECL cairo >= 0.1.0)

cairo_pattern_get_filterDescription

Description

cairo_pattern_get_filter ( CairoSurfacePattern $pattern ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_filter() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_linear_points

(PECL cairo >= 0.1.0)

cairo_pattern_get_linear_pointsDescription

Description

cairo_pattern_get_linear_points ( CairoLinearGradient $pattern ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_linear_points() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_matrix

(PECL cairo >= 0.1.0)

cairo_pattern_get_matrixDescription

Description

cairo_pattern_get_matrix ( CairoPattern $pattern ) : CairoMatrix

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_matrix() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_radial_circles

(PECL cairo >= 0.1.0)

cairo_pattern_get_radial_circlesDescription

Description

cairo_pattern_get_radial_circles ( CairoRadialGradient $pattern ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_radial_circles() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_rgba

(PECL cairo >= 0.1.0)

cairo_pattern_get_rgbaDescription

Description

cairo_pattern_get_rgba ( CairoSolidPattern $pattern ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_rgba() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_surface

(PECL cairo >= 0.1.0)

cairo_pattern_get_surfaceDescription

Description

cairo_pattern_get_surface ( CairoSurfacePattern $pattern ) : CairoSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_surface() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_get_type

(PECL cairo >= 0.1.0)

cairo_pattern_get_typeDescription

Description

cairo_pattern_get_type ( CairoPattern $pattern ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_get_type() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_set_extend

(PECL cairo >= 0.1.0)

cairo_pattern_set_extendDescription

Description

cairo_pattern_set_extend ( string $pattern , string $extend ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

extend

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_set_extend() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_set_filter

(PECL cairo >= 0.1.0)

cairo_pattern_set_filterDescription

Description

cairo_pattern_set_filter ( CairoSurfacePattern $pattern , int $filter ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

filter

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_set_filter() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_set_matrix

(PECL cairo >= 0.1.0)

cairo_pattern_set_matrixDescription

Description

cairo_pattern_set_matrix ( CairoPattern $pattern , CairoMatrix $matrix ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

matrix

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_set_matrix() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pattern_status

(PECL cairo >= 0.1.0)

cairo_pattern_statusDescription

Description

cairo_pattern_status ( CairoPattern $pattern ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

pattern

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pattern_status() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pdf_surface_create

(PECL cairo >= 0.1.0)

cairo_pdf_surface_createDescription

Description

cairo_pdf_surface_create ( string $file , float $width , float $height ) : CairoPdfSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pdf_surface_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_pdf_surface_set_size

(PECL cairo >= 0.1.0)

cairo_pdf_surface_set_sizeDescription

Description

cairo_pdf_surface_set_size ( CairoPdfSurface $surface , float $width , float $height ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_pdf_surface_set_size() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_get_levels

(PECL cairo >= 0.1.0)

cairo_ps_get_levelsDescription

Description

cairo_ps_get_levels ( void ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_get_levels() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_level_to_string

(PECL cairo >= 0.1.0)

cairo_ps_level_to_stringDescription

Description

cairo_ps_level_to_string ( int $level ) : string

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

level

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_level_to_string() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_create

(PECL cairo >= 0.1.0)

cairo_ps_surface_createDescription

Description

cairo_ps_surface_create ( string $file , float $width , float $height ) : CairoPsSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_dsc_begin_page_setup

(PECL cairo >= 0.1.0)

cairo_ps_surface_dsc_begin_page_setupDescription

Description

cairo_ps_surface_dsc_begin_page_setup ( CairoPsSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_dsc_begin_page_setup() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_dsc_begin_setup

(PECL cairo >= 0.1.0)

cairo_ps_surface_dsc_begin_setupDescription

Description

cairo_ps_surface_dsc_begin_setup ( CairoPsSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_dsc_begin_setup() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_dsc_comment

(PECL cairo >= 0.1.0)

cairo_ps_surface_dsc_commentDescription

Description

cairo_ps_surface_dsc_comment ( CairoPsSurface $surface , string $comment ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

comment

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_dsc_comment() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_get_eps

(PECL cairo >= 0.1.0)

cairo_ps_surface_get_epsDescription

Description

cairo_ps_surface_get_eps ( CairoPsSurface $surface ) : bool

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_get_eps() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_restrict_to_level

(PECL cairo >= 0.1.0)

cairo_ps_surface_restrict_to_levelDescription

Description

cairo_ps_surface_restrict_to_level ( CairoPsSurface $surface , int $level ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

level

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_restrict_to_level() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_set_eps

(PECL cairo >= 0.1.0)

cairo_ps_surface_set_epsDescription

Description

cairo_ps_surface_set_eps ( CairoPsSurface $surface , bool $level ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

level

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_set_eps() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_ps_surface_set_size

(PECL cairo >= 0.1.0)

cairo_ps_surface_set_sizeDescription

Description

cairo_ps_surface_set_size ( CairoPsSurface $surface , float $width , float $height ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_ps_surface_set_size() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_create

(PECL cairo >= 0.1.0)

cairo_scaled_font_createDescription

Description

cairo_scaled_font_create ( CairoFontFace $fontface , CairoMatrix $matrix , CairoMatrix $ctm , CairoFontOptions $fontoptions ) : CairoScaledFont

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

fontface

Description...

matrix

Description...

ctm

Description...

fontoptions

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_extents

(PECL cairo >= 0.1.0)

cairo_scaled_font_extentsDescription

Description

cairo_scaled_font_extents ( CairoScaledFont $scaledfont ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_extents() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_ctm

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_ctmDescription

Description

cairo_scaled_font_get_ctm ( CairoScaledFont $scaledfont ) : CairoMatrix

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_ctm() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_font_face

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_font_faceDescription

Description

cairo_scaled_font_get_font_face ( CairoScaledFont $scaledfont ) : CairoFontFace

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_font_face() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_font_matrix

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_font_matrixDescription

Description

cairo_scaled_font_get_font_matrix ( CairoScaledFont $scaledfont ) : CairoFontOptions

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_font_matrix() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_font_options

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_font_optionsDescription

Description

cairo_scaled_font_get_font_options ( CairoScaledFont $scaledfont ) : CairoFontOptions

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_font_options() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_scale_matrix

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_scale_matrixDescription

Description

cairo_scaled_font_get_scale_matrix ( CairoScaledFont $scaledfont ) : CairoMatrix

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_scale_matrix() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_get_type

(PECL cairo >= 0.1.0)

cairo_scaled_font_get_typeDescription

Description

cairo_scaled_font_get_type ( CairoScaledFont $scaledfont ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_get_type() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_glyph_extents

(PECL cairo >= 0.1.0)

cairo_scaled_font_glyph_extentsDescription

Description

cairo_scaled_font_glyph_extents ( CairoScaledFont $scaledfont , array $glyphs ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

glyphs

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_glyph_extents() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_status

(PECL cairo >= 0.1.0)

cairo_scaled_font_statusDescription

Description

cairo_scaled_font_status ( CairoScaledFont $scaledfont ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_status() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_scaled_font_text_extents

(PECL cairo >= 0.1.0)

cairo_scaled_font_text_extentsDescription

Description

cairo_scaled_font_text_extents ( CairoScaledFont $scaledfont , string $text ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

scaledfont

Description...

text

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_scaled_font_text_extents() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_copy_page

(PECL cairo >= 0.1.0)

cairo_surface_copy_pageDescription

Description

cairo_surface_copy_page ( CairoSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_copy_page() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_create_similar

(PECL cairo >= 0.1.0)

cairo_surface_create_similarDescription

Description

cairo_surface_create_similar ( CairoSurface $surface , int $content , float $width , float $height ) : CairoSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

content

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_create_similar() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_finish

(PECL cairo >= 0.1.0)

cairo_surface_finishDescription

Description

cairo_surface_finish ( CairoSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_finish() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_flush

(PECL cairo >= 0.1.0)

cairo_surface_flushDescription

Description

cairo_surface_flush ( CairoSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_flush() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_get_content

(PECL cairo >= 0.1.0)

cairo_surface_get_contentDescription

Description

cairo_surface_get_content ( CairoSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_get_content() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_get_device_offset

(PECL cairo >= 0.1.0)

cairo_surface_get_device_offsetDescription

Description

cairo_surface_get_device_offset ( CairoSurface $surface ) : array

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_get_device_offset() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_get_font_options

(PECL cairo >= 0.1.0)

cairo_surface_get_font_optionsDescription

Description

cairo_surface_get_font_options ( CairoSurface $surface ) : CairoFontOptions

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_get_font_options() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_get_type

(PECL cairo >= 0.1.0)

cairo_surface_get_typeDescription

Description

cairo_surface_get_type ( CairoSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_get_type() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_mark_dirty_rectangle

(PECL cairo >= 0.1.0)

cairo_surface_mark_dirty_rectangleDescription

Description

cairo_surface_mark_dirty_rectangle ( CairoSurface $surface , float $x , float $y , float $width , float $height ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

x

Description...

y

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_mark_dirty_rectangle() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_mark_dirty

(PECL cairo >= 0.1.0)

cairo_surface_mark_dirtyDescription

Description

cairo_surface_mark_dirty ( CairoSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_mark_dirty() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_set_device_offset

(PECL cairo >= 0.1.0)

cairo_surface_set_device_offsetDescription

Description

cairo_surface_set_device_offset ( CairoSurface $surface , float $x , float $y ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

x

Description...

y

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_set_device_offset() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_set_fallback_resolution

(PECL cairo >= 0.1.0)

cairo_surface_set_fallback_resolutionDescription

Description

cairo_surface_set_fallback_resolution ( CairoSurface $surface , float $x , float $y ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

x

Description...

y

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_set_fallback_resolution() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_show_page

(PECL cairo >= 0.1.0)

cairo_surface_show_pageDescription

Description

cairo_surface_show_page ( CairoSurface $surface ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_show_page() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_status

(PECL cairo >= 0.1.0)

cairo_surface_statusDescription

Description

cairo_surface_status ( CairoSurface $surface ) : int

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_status() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_surface_write_to_png

(PECL cairo >= 0.1.0)

cairo_surface_write_to_pngDescription

Description

cairo_surface_write_to_png ( CairoSurface $surface , resource $stream ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

stream

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_surface_write_to_png() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_svg_surface_create

(PECL cairo >= 0.1.0)

cairo_svg_surface_createDescription

Description

cairo_svg_surface_create ( string $file , float $width , float $height ) : CairoSvgSurface

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_svg_surface_create() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_svg_surface_restrict_to_version

(PECL cairo >= 0.1.0)

cairo_svg_surface_restrict_to_versionDescription

Description

cairo_svg_surface_restrict_to_version ( CairoSvgSurface $surface , int $version ) : void

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

version

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_svg_surface_restrict_to_version() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()



cairo_svg_version_to_string

(PECL cairo >= 0.1.0)

cairo_svg_version_to_stringDescription

Description

cairo_svg_version_to_string ( int $version ) : string

The function description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

version

Description...

Return Values

What is returned on success and failure

Errors/Exceptions

When does this function issue E_* level errors, and/or throw exceptions.

Examples

Example #1 cairo_svg_version_to_string() example

Any text that describes the purpose of the example, or what goes on in the example should be here.

<?php

/* ... */

?>

The above example will output something similar to:

   ...
   

See Also

  • related function name here()


Table of Contents



The Cairo class

(PECL cairo >= 0.1.0)

Introduction

Simple class with some static helper methods.

Class synopsis

Cairo {
/* Methods */
public static availableFonts ( void ) : array
public static availableSurfaces ( void ) : array
public static statusToString ( int $status ) : string
public static version ( void ) : int
public static versionString ( void ) : string
}

Cairo::availableFonts

cairo_available_fonts

(PECL cairo >= 0.1.0)

Cairo::availableFonts -- cairo_available_fontsRetrieves the availables font types

Description

Object oriented style:

public static Cairo::availableFonts ( void ) : array

Procedural style:

cairo_available_fonts ( void ) : array

Returns an array with the available font backends

Parameters

This function has no parameters.

Return Values

A list-type array with all available font backends.

Examples

Example #1 Object oriented style

<?php

/* Object Oriented Style */
var_dump(Cairo::availableFonts());

?>

The above example will output something similar to:

   array(2) {
     [0]=>
     string(5) "WIN32"
     [1]=>
     string(4) "USER"
   }
   

Example #2 Procedural style

<?php

/* Procedural style */
var_dump(cairo_available_fonts());

?>

The above example will output something similar to:

   array(2) {
     [0]=>
     string(5) "WIN32"
     [1]=>
     string(4) "USER"
   }
   

See Also



Cairo::availableSurfaces

cairo_available_surfaces

(PECL cairo >= 0.1.0)

Cairo::availableSurfaces -- cairo_available_surfacesRetrieves all available surfaces

Description

Object oriented style (method):

public static Cairo::availableSurfaces ( void ) : array

Procedural style:

cairo_available_surfaces ( void ) : array

Returns an array with the available surface backends

Parameters

This function has no parameters.

Return Values

A list-type array with all available surface backends.

Examples

Example #1 Object oriented style

<?php

/* Object Oriented style */
var_dump(Cairo::availableSurfaces());

?>

The above example will output something similar to:

   array(6) {
     [0]=>
     string(5) "IMAGE"
     [1]=>
     string(3) "PNG"
     [2]=>
     string(3) "PDF"
     [3]=>
     string(2) "PS"
     [4]=>
     string(3) "SVG"
     [5]=>
     string(5) "WIN32"
   }
   

Example #2 Procedural style

<?php

/* Procedural style */
var_dump(cairo_available_surfaces());

?>

The above example will output something similar to:

   array(6) {
     [0]=>
     string(5) "IMAGE"
     [1]=>
     string(3) "PNG"
     [2]=>
     string(3) "PDF"
     [3]=>
     string(2) "PS"
     [4]=>
     string(3) "SVG"
     [5]=>
     string(5) "WIN32"
   }
   

See Also



Cairo::statusToString

cairo_status_to_string

(PECL cairo >= 0.1.0)

Cairo::statusToString -- cairo_status_to_stringRetrieves the current status as string

Description

Object oriented style (method):

public static Cairo::statusToString ( int $status ) : string

Procedural style:

cairo_status_to_string ( int $status ) : string

Retrieves the current status as a readable string

Parameters

status

A valid status code given by cairo_status() or CairoContext::status()

Return Values

A string containing the current status of a CairoContext object

Examples

Example #1 Object oriented style

<?php
$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);
$context = new CairoContext($surface);

var_dump(Cairo::statusToString($context->status()));
?>

The above example will output something similar to:

   string(7) "success"
   

Example #2 Procedural style

<?php
$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);
$context cairo_create($surface);

var_dump(cairo_status_to_string(cairo_status($context)));
?>

The above example will output something similar to:

   string(7) "success"
   

See Also



Cairo::version

cairo_version

(PECL cairo >= 0.1.0)

Cairo::version -- cairo_versionRetrieves cairo's library version

Description

Object oriented style (method):

public static Cairo::version ( void ) : int

Procedural style:

cairo_version ( void ) : int

Retrieves the current version of the cairo library as an integer value

Parameters

This function has no parameters.

Return Values

Current Cairo library version integer

Examples

Example #1 Object oriented style

<?php
var_dump
(Cairo::version());
?>

The above example will output something similar to:

   int(10808)
   

Example #2 Procedural style

<?php
var_dump
(cairo_version());
?>

The above example will output something similar to:

   int(10808)
   

See Also



Cairo::versionString

cairo_version_string

(PECL cairo >= 0.1.0)

Cairo::versionString -- cairo_version_stringRetrieves cairo version as string

Description

Object oriented style (method):

public static Cairo::versionString ( void ) : string

Procedural style:

cairo_version_string ( void ) : string

Retrieves the current cairo library version as a string.

Parameters

This function has no parameters.

Return Values

Current Cairo library version string

Examples

Example #1 Object oriented style

<?php

var_dump
(Cairo::versionString());

?>

The above example will output something similar to:

   string(5) "1.8.8"
   

Example #2 Procedural style

<?php

var_dump
(cairo_version_string());

?>

The above example will output something similar to:

   string(5) "1.8.8"
   

See Also


Table of Contents



The CairoContext class

(PECL cairo >= 0.1.0)

Introduction

Context is the main object used when drawing with cairo. To draw with cairo, you create a CairoContext, set the target CairoSurface, and drawing options for the CairoContext, create shapes with functions . like CairoContext::moveTo() and CairoContext::lineTo(), and then draw shapes with CairoContext::stroke() or CairoContext::fill(). Contexts can be pushed to a stack via CairoContext::save(). They may then safely be changed, without losing the current state. Use CairoContext::restore() to restore to the saved state.

Class synopsis

CairoContext {
/* Methods */
public appendPath ( CairoPath $path ) : void
public arc ( float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void
public arcNegative ( float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void
public clip ( void ) : void
public clipExtents ( void ) : array
public clipPreserve ( void ) : void
public clipRectangleList ( void ) : array
public closePath ( void ) : void
public __construct ( CairoSurface $surface )
public copyPage ( void ) : void
public copyPath ( void ) : CairoPath
public copyPathFlat ( void ) : CairoPath
public curveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void
public deviceToUser ( float $x , float $y ) : array
public deviceToUserDistance ( float $x , float $y ) : array
public fill ( void ) : void
public fillExtents ( void ) : array
public fillPreserve ( void ) : void
public fontExtents ( void ) : array
public getAntialias ( void ) : int
public getCurrentPoint ( void ) : array
public getDash ( void ) : array
public getDashCount ( void ) : int
public getFillRule ( void ) : int
public getFontFace ( void ) : void
public getFontMatrix ( void ) : void
public getFontOptions ( void ) : void
public getGroupTarget ( void ) : void
public getLineCap ( void ) : int
public getLineJoin ( void ) : int
public getLineWidth ( void ) : float
public getMatrix ( void ) : void
public getMiterLimit ( void ) : float
public getOperator ( void ) : int
public getScaledFont ( void ) : void
public getSource ( void ) : void
public getTarget ( void ) : void
public getTolerance ( void ) : float
public glyphPath ( array $glyphs ) : void
public hasCurrentPoint ( void ) : bool
public identityMatrix ( void ) : void
public inFill ( float $x , float $y ) : bool
public inStroke ( float $x , float $y ) : bool
public lineTo ( float $x , float $y ) : void
public mask ( CairoPattern $pattern ) : void
public maskSurface ( CairoSurface $surface [, float $x [, float $y ]] ) : void
public moveTo ( float $x , float $y ) : void
public newPath ( void ) : void
public newSubPath ( void ) : void
public paint ( void ) : void
public paintWithAlpha ( float $alpha ) : void
public pathExtents ( void ) : array
public popGroup ( void ) : void
public popGroupToSource ( void ) : void
public pushGroup ( void ) : void
public pushGroupWithContent ( int $content ) : void
public rectangle ( float $x , float $y , float $width , float $height ) : void
public relCurveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void
public relLineTo ( float $x , float $y ) : void
public relMoveTo ( float $x , float $y ) : void
public resetClip ( void ) : void
public restore ( void ) : void
public rotate ( float $angle ) : void
public save ( void ) : void
public scale ( float $x , float $y ) : void
public selectFontFace ( string $family [, int $slant [, int $weight ]] ) : void
public setAntialias ([ int $antialias ] ) : void
public setDash ( array $dashes [, float $offset ] ) : void
public setFillRule ( int $setting ) : void
public setFontFace ( CairoFontFace $fontface ) : void
public setFontMatrix ( CairoMatrix $matrix ) : void
public setFontOptions ( CairoFontOptions $fontoptions ) : void
public setFontSize ( float $size ) : void
public setLineCap ( int $setting ) : void
public setLineJoin ( int $setting ) : void
public setLineWidth ( float $width ) : void
public setMatrix ( CairoMatrix $matrix ) : void
public setMiterLimit ( float $limit ) : void
public setOperator ( int $setting ) : void
public setScaledFont ( CairoScaledFont $scaledfont ) : void
public setSource ( CairoPattern $pattern ) : void
public setSourceRGB ( float $red , float $green , float $blue ) : void
public setSourceRGBA ( float $red , float $green , float $blue , float $alpha ) : void
public setSourceSurface ( CairoSurface $surface [, float $x [, float $y ]] ) : void
public setTolerance ( float $tolerance ) : void
public showPage ( void ) : void
public showText ( string $text ) : void
public status ( void ) : int
public stroke ( void ) : void
public strokeExtents ( void ) : array
public strokePreserve ( void ) : void
public textExtents ( string $text ) : array
public textPath ( string $string ) : void
public transform ( CairoMatrix $matrix ) : void
public translate ( float $x , float $y ) : void
public userToDevice ( float $x , float $y ) : array
public userToDeviceDistance ( float $x , float $y ) : array
}

CairoContext::appendPath

cairo_append_path

(PECL cairo >= 0.1.0)

CairoContext::appendPath -- cairo_append_pathAppends a path to current path

Description

Object oriented style (method):

public CairoContext::appendPath ( CairoPath $path ) : void

Procedural style:

cairo_append_path ( CairoContext $context , CairoPath $path ) : void

Appends the path onto the current path. The path may be either the return value from one of CairoContext::copyPath() or CairoContext::copyPathFlat();

if path is not a valid CairoPath instance a CairoException will be thrown

Parameters

context

CairoContext object

path

CairoPath object

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

$path $context->copyPath();

$context->appendPath($path);

?>

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

$path cairo_copy_path($context);

cairo_append_path($context$path);

?>

See Also



CairoContext::arc

cairo_arc

(PECL cairo >= 0.1.0)

CairoContext::arc -- cairo_arcAdds a circular arc

Description

Object oriented style (method):

public CairoContext::arc ( float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void

Procedural style:

cairo_arc ( CairoContext $context , float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void

Adds a circular arc of the given radius to the current path. The arc is centered at (x, y), begins at angle1 and proceeds in the direction of increasing angles to end at angle2. If angle2 is less than angle1 it will be progressively increased by 2*M_PI until it is greater than angle1. If there is a current point, an initial line segment will be added to the path to connect the current point to the beginning of the arc. If this initial line is undesired, it can be avoided by calling CairoContext::newSubPath() or procedural cairo_new_sub_path() before calling CairoContext::arc() or cairo_arc(). Angles are measured in radians. An angle of 0.0 is in the direction of the positive X axis (in user space). An angle of M_PI/2.0 radians (90 degrees) is in the direction of the positive Y axis (in user space). Angles increase in the direction from the positive X axis toward the positive Y axis. So with the default transformation matrix, angles increase in a clockwise direction. (To convert from degrees to radians, use degrees * (M_PI / 180.).) This function gives the arc in the direction of increasing angles; see CairoContext::arcNegative() or cairo_arc_negative() to get the arc in the direction of decreasing angles.

Parameters

context

A valid CairoContext object

x

x position

y

y position

radius

Radius of the arc

angle1

start angle

angle2

end angle

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

$c->setSourceRgb(000);
$c->paint();

$c->setLineWidth(1);
$c->setSourceRgb(111);

for (
$r 50$r 0$r -= 10) {
 
$c->arc(5050$r0M_PI);
 
$c->stroke();
 
$c->fill();
}

$s->writeToPng(dirname(__FILE__) . '/CairoContext__arc.png');
?>

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_set_source_rgb($c000);
cairo_paint($c);

cairo_set_source_rgb($c111);
cairo_set_line_width($c1);

for (
$r 50$r 0$r -= 10) {
 
cairo_arc($c5050$r0M_PI);
 
cairo_stroke($c);
 
cairo_fill($c);
}

cairo_surface_write_to_png($sdirname(__FILE__) . '/cairo_arc.png');
?>

See Also



CairoContext::arcNegative

cairo_arc_negative

(PECL cairo >= 0.1.0)

CairoContext::arcNegative -- cairo_arc_negativeAdds a negative arc

Description

Object oriented style (method):

public CairoContext::arcNegative ( float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void

Procedural style:

cairo_arc_negative ( CairoContext $context , float $x , float $y , float $radius , float $angle1 , float $angle2 ) : void

Adds a circular arc of the given radius to the current path. The arc is centered at (x, y), begins at angle1 and proceeds in the direction of decreasing angles to end at angle2. If angle2 is greater than angle1 it will be progressively decreased by 2*M_PI until it is less than angle1. See CairoContext::arc() or cairo_arc() for more details. This function differs only in the direction of the arc between the two angles.

Parameters

context

A valid CairoContext object

x

double x position

y

double y position

radius

The radius of the desired negative arc

angle1

Start angle of the arc

angle2

End angle of the arc

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

$c->setSourceRgb(000);
$c->paint();

$c->setLineWidth(1);
$c->setSourceRgb(111);

for (
$r 50$r 0$r -= 10) {
 
$c->arcNegative(5050$rM_PI0);
 
$c->stroke();
 
$c->fill();
}

$s->writeToPng(dirname(__FILE__) . '/CairoContext__arcNegative.png');
?>

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_set_source_rgb($c000);
cairo_paint($c);

cairo_set_source_rgb($c111);
cairo_set_line_width($c1);

for (
$r 50$r 0$r -= 10) {
 
cairo_arc_negative($c5050$rM_PI0);
 
cairo_stroke($c);
 
cairo_fill($c);
}

cairo_surface_write_to_png($sdirname(__FILE__) . '/cairo_arc_negative.png');
?>

See Also



CairoContext::clip

cairo_clip

(PECL cairo >= 0.1.0)

CairoContext::clip -- cairo_clipEstablishes a new clip region

Description

Object oriented style (method):

public CairoContext::clip ( void ) : void

Procedural style:

cairo_clip ( CairoContext $context ) : void

Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by CairoContext::fill() or cairo_fill() and according to the current fill rule (see CairoContext::setFillRule() or cairo_set_fill_rule()).

After CairoContext::clip() or cairo_clip(), the current path will be cleared from the cairo context.

The current clip region affects all drawing operations by effectively masking out any changes to the surface that are outside the current clip region.

Calling CairoContext::clip() or cairo_clip() can only make the clip region smaller, never larger. But the current clip is part of the graphics state, so a temporary restriction of the clip region can be achieved by calling CairoContext::clip() or cairo_clip() within a CairoContext::save()/CairoContext::restore() or cairo_save()/cairo_restore() pair. The only other means of increasing the size of the clip region is CairoContext::resetClip() or procedural cairo_reset_clip().

Parameters

context

A valid CairoContext object

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

$context->clip();

?>

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

cairo_clip($context);

?>

See Also



CairoContext::clipExtents

cairo_clip_extents

(PECL cairo >= 0.1.0)

CairoContext::clipExtents -- cairo_clip_extentsComputes the area inside the current clip

Description

Object oriented style (method):

public CairoContext::clipExtents ( void ) : array

Procedural style:

cairo_clip_extents ( CairoContext $context ) : array

Computes a bounding box in user coordinates covering the area inside the current clip.

Parameters

context

A valid CairoContext object

Return Values

An array containing the (float)x1, (float)y1, (float)x2, (float)y2, coordinates covering the area inside the current clip

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

var_dump($context->clipExtents());
?>

The above example will output something similar to:

   array(4) {
     [0]=>
     float(0)
     [1]=>
     float(0)
     [2]=>
     float(50)
     [3]=>
     float(50)
   }
   

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

var_dump(cairo_clip_extents($context));

?>

The above example will output something similar to:

   array(4) {
     [0]=>
     float(0)
     [1]=>
     float(0)
     [2]=>
     float(50)
     [3]=>
     float(50)
   }
   

See Also



CairoContext::clipPreserve

cairo_clip_preserve

(PECL cairo >= 0.1.0)

CairoContext::clipPreserve -- cairo_clip_preserveEstablishes a new clip region from the current clip

Description

Object oriented style (method):

public CairoContext::clipPreserve ( void ) : void

Procedural style:

cairo_clip_preserve ( CairoContext $context ) : void

Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by Context.fill() and according to the current FILL RULE (see CairoContext::setFillRule() or cairo_set_fill_rule()).

Unlike CairoContext::clip(), CairoContext::clipPreserve() preserves the path within the Context. The current clip region affects all drawing operations by effectively masking out any changes to the surface that are outside the current clip region.

Calling CairoContext::clipPreserve() can only make the clip region smaller, never larger. But the current clip is part of the graphics state, so a temporary restriction of the clip region can be achieved by calling CairoContext::clipPreserve() within a CairoContext::save()/CairoContext::restore() pair. The only other means of increasing the size of the clip region is CairoContext::resetClip().

Parameters

context

A valid CairoContext object

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

$context->clipPreserve();

?>

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

cairo_clip_preserve($context);

?>

See Also



CairoContext::clipRectangleList

cairo_clip_rectangle_list

(PECL cairo >= 0.1.0)

CairoContext::clipRectangleList -- cairo_clip_rectangle_listRetrieves the current clip as a list of rectangles

Description

Object oriented style (method):

public CairoContext::clipRectangleList ( void ) : array

Procedural style:

cairo_clip_rectangle_list ( CairoContext $context ) : array

Returns a list-type array with the current clip region as a list of rectangles in user coordinates

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

An array of user-space represented rectangles for the current clip

(The status in the list may be CAIRO_STATUS_CLIP_NOT_REPRESENTABLE to indicate that the clip region cannot be represented as a list of user-space rectangles. The status may have other values to indicate other errors.)

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

var_dump($context->clipRectangleList());

?>

The above example will output something similar to:

   array(1) {
     [0]=>
     array(4) {
       ["x"]=>
       float(0)
       ["y"]=>
       float(0)
       ["width"]=>
       float(50)
       ["height"]=>
       float(50)
     }
   }
   

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

var_dump(cairo_clip_rectangle_list($context));

?>

The above example will output something similar to:

   array(1) {
     [0]=>
     array(4) {
       ["x"]=>
       float(0)
       ["y"]=>
       float(0)
       ["width"]=>
       float(50)
       ["height"]=>
       float(50)
     }
   }
   

See Also

  • Classname::Method()



CairoContext::closePath

cairo_close_path

(PECL cairo >= 0.1.0)

CairoContext::closePath -- cairo_close_pathCloses the current path

Description

Object oriented style (method):

public CairoContext::closePath ( void ) : void

Procedural style:

cairo_close_path ( CairoContext $context ) : void

Adds a line segment to the path from the current point to the beginning of the current sub-path, (the most recent point passed to CairoContext::moveTo()), and closes this sub-path. After this call the current point will be at the joined endpoint of the sub-path.

The behavior of close_path() is distinct from simply calling CairoContext::lineTo() with the equivalent coordinate in the case of stroking. When a closed sub-path is stroked, there are no caps on the ends of the sub-path. Instead, there is a line join connecting the final and initial segments of the sub-path.

If there is no current point before the call to CairoContext::closePath(), this function will have no effect.

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

$context->closePath();

?>

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

cairo_close_path($context);

?>

See Also



CairoContext::__construct

(PECL cairo >= 0.1.0)

CairoContext::__constructCreates a new CairoContext

Description

public CairoContext::__construct ( CairoSurface $surface )

Creates a new CairoContext object to draw

Parameters

surface

A valid CairoSurface like CairoImageSurface or CairoPdfSurface

Return Values

A CairoContext

Examples

Example #1 CairoContext::__construct() example

<?php
// The surface to work on
$surface = new CairoImageSurface(CairoFormat::ARGB325050);

// Create a new CairoContext for the CairoSurface
$context = new CairoContext($surface);

?>

See Also

  • Cairo::Method()



CairoContext::copyPage

cairo_copy_page

(PECL cairo >= 0.1.0)

CairoContext::copyPage -- cairo_copy_pageEmits the current page

Description

Object oriented style (method):

public CairoContext::copyPage ( void ) : void

Procedural style:

cairo_copy_page ( CairoContext $context ) : void

Emits the current page for backends that support multiple pages, but doesn’t clear it, so, the contents of the current page will be retained for the next page too. Use CairoContext::showPage() if you want to get an empty page after the emission.

This is a convenience function that simply calls CairoSurface::copyPage() on CairoContext’s target.

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

$context->copyPage();

?>

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

cairo_copy_page($context);

?>

See Also



CairoContext::copyPath

cairo_copy_path

(PECL cairo >= 0.1.0)

CairoContext::copyPath -- cairo_copy_pathCreates a copy of the current path

Description

Object oriented style (method):

public CairoContext::copyPath ( void ) : CairoPath

Procedural style:

cairo_copy_path ( CairoContext $context ) : CairoPath

Creates a copy of the current path and returns it to the user as a CairoPath. See CairoPath for hints on how to iterate over the returned data structure.

This function will always return a valid CairoPath object, but the result will have no data, if either of the following conditions hold:

  • 1. If there is insufficient memory to copy the path. In this case CairoPath->status will be set to CAIRO_STATUS_NO_MEMORY.
  • 2. If context is already in an error state. In this case CairoPath->status will contain the same status that would be returned by cairo_status().
In either case, CairoPath->status will be set to CAIRO_STATUS_NO_MEMORY (regardless of what the error status in cr might have been).

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

A copy of the current CairoPath in the context

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

var_dump($context->copyPath())

?>

The above example will output something similar to:

   object(CairoPath)#3 (0) {
   }
   

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

var_dump(cairo_copy_path($context));

?>

The above example will output something similar to:

   object(CairoPath)#3 (0) {
   }
   

See Also



CairoContext::copyPathFlat

cairo_copy_path_flat

(PECL cairo >= 0.1.0)

CairoContext::copyPathFlat -- cairo_copy_path_flatGets a flattened copy of the current path

Description

Object oriented style (method):

public CairoContext::copyPathFlat ( void ) : CairoPath

Procedural style:

cairo_copy_path_flat ( CairoContext $context ) : CairoPath

Gets a flattened copy of the current path and returns it to the user as a CairoPath.

This function is like CairoContext::copyPath() except that any curves in the path will be approximated with piecewise-linear approximations, (accurate to within the current tolerance value). That is, the result is guaranteed to not have any elements of type CAIRO_PATH_CURVE_TO which will instead be replaced by a series of CAIRO_PATH_LINE_TO elements.

Parameters

context

A CairoContext object

Return Values

A copy of the current path

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

$context = new CairoContext($surface);

var_dump($context->copyPathFlat());

?>

The above example will output something similar to:

   object(CairoPath)#3 (0) {
   }
   

Example #2 Procedural style

<?php

$surface 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);

$context cairo_create($surface);

var_dump(cairo_copy_path_flat($context));

?>

The above example will output something similar to:

   object(CairoPath)#3 (0) {
   }
   

See Also



CairoContext::curveTo

cairo_curve_to

(PECL cairo >= 0.1.0)

CairoContext::curveTo -- cairo_curve_toAdds a curve

Description

Object oriented style (method):

public CairoContext::curveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void

Procedural style:

cairo_curve_to ( CairoContext $context , float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void

Adds a cubic Bezier spline to the path from the current point to position x3 ,y3 in user-space coordinates, using x1, y1 and x2, y2 as the control points. After this call the current point will be x3, y3.

If there is no current point before the call to CairoContext::curveTo() this function will behave as if preceded by a call to CairoContext::moveTo() (x1, y1).

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

x1

First control point in the x axis for the curve

y1

First control point in the y axis for the curve

x2

Second control point in x axis for the curve

y2

Second control point in y axis for the curve

x3

Final point in the x axis for the curve

y3

Final point in the y axis for the curve

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php
$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

$c->setSourceRgb(000);

$c->paint();

$c->moveTo(1050); 
$c->setLineWidth(5);
$c->setSourceRgb(.101);
$c->curveTo(208080209050); 
$c->stroke();

$s->writeToPng(dirname(__FILE__) . '/curveTo.png');
?>

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_set_source_rgb($c000);

cairo_paint($c);

cairo_move_to($c1050);
cairo_set_line_width($c5);
cairo_set_source_rgb($c.101);
cairo_curve_to($c208080209050);
cairo_stroke($c);

cairo_surface_write_to_png($sdirname(__FILE__) . '/curve_to.png');
?>

See Also



CairoContext::deviceToUser

cairo_device_to_user

(PECL cairo >= 0.1.0)

CairoContext::deviceToUser -- cairo_device_to_userTransform a coordinate

Description

Object oriented style (method):

public CairoContext::deviceToUser ( float $x , float $y ) : array

Procedural style:

cairo_device_to_user ( CairoContext $context , float $x , float $y ) : array

Transform a coordinate from device space to user space by multiplying the given point by the inverse of the current transformation matrix (CTM).

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

x

x value of the coordinate

y

y value of the coordinate

Return Values

An array containing the x and y coordinates in the user-space

See Also



CairoContext::deviceToUserDistance

cairo_device_to_user_distance

(PECL cairo >= 0.1.0)

CairoContext::deviceToUserDistance -- cairo_device_to_user_distanceTransform a distance

Description

Object oriented style (method):

public CairoContext::deviceToUserDistance ( float $x , float $y ) : array

Procedural style:

cairo_device_to_user_distance ( CairoContext $context , float $x , float $y ) : array

Transform a distance vector from device space to user space. This function is similar to CairoContext::deviceToUser() or cairo_device_to_user() except that the translation components of the inverse Cairo Transformation Matrix will be ignored when transforming (x,y).

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

x

X component of a distance vector

y

Y component of a distance vector

Return Values

Returns an array with the x and y values of a distance vector in the user-space

See Also



CairoContext::fill

cairo_fill

(PECL cairo >= 0.1.0)

CairoContext::fill -- cairo_fillFills the current path

Description

Object oriented style (method):

public CairoContext::fill ( void ) : void

Procedural style:

cairo_fill ( CairoContext $context ) : void

A drawing operator that fills the current path according to the current CairoFillRule, (each sub-path is implicitly closed before being filled). After CairoContext::fill() or cairo_fill(), the current path will be cleared from the CairoContext.

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);
 
$c->setSourceRgb(000);
$c->paint();

$c->setSourceRgb(111);
$c->rectangle(005050);
$c->fill();
$c->setSourceRgb(010);
$c->rectangle(50505050);
$c->fill();

$s->writeToPng(dirname(__FILE__) . '/CairoContext_fill.png');

?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_set_source_rgb($c000);
cairo_paint($c);

cairo_set_source_rgb($c111);
cairo_rectangle($c005050);
cairo_fill($c);
cairo_set_source_rgb($c010);
cairo_rectangle($c50505050);
cairo_fill($c);

cairo_surface_write_to_png($sdirname(__FILE__) . '/cairo_fill.png');

?>

The above example will output something similar to:

   ...
   

See Also



CairoContext::fillExtents

cairo_fill_extents

(PECL cairo >= 0.1.0)

CairoContext::fillExtents -- cairo_fill_extentsComputes the filled area

Description

Object oriented style (method):

public CairoContext::fillExtents ( void ) : array

Procedural style:

cairo_fill_extents ( CairoContext $context ) : array

Computes a bounding box in user coordinates covering the area that would be affected, (the “inked” area), by a CairoContext::fill() operation given the current path and fill parameters. If the current path is empty, returns an empty rectangle (0,0,0,0). Surface dimensions and clipping are not taken into account.

Contrast with CairoContext::pathExtents(), which is similar, but returns non-zero extents for some paths with no inked area, (such as a simple line segment).

Note that CairoContext::fillExtents() must necessarily do more work to compute the precise inked areas in light of the fill rule, so CairoContext::pathExtents() may be more desirable for sake of performance if the non-inked path extents are desired.

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

An array with the coordinates of the afected area

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also



CairoContext::fillPreserve

cairo_fill_preserve

(PECL cairo >= 0.1.0)

CairoContext::fillPreserve -- cairo_fill_preserveFills and preserve the current path

Description

Object oriented style (method):

public CairoContext::fillPreserve ( void ) : void

Procedural style:

cairo_fill_preserve ( CairoContext $context ) : void

A drawing operator that fills the current path according to the current CairoFillRule, (each sub-path is implicitly closed before being filled). Unlike CairoContext::fill(), CairoContext::fillPreserve() (Procedural cairo_fill(), cairo_fill_preserve(), respectively) preserves the path within the Context.

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also



CairoContext::fontExtents

cairo_font_extents

(PECL cairo >= 0.1.0)

CairoContext::fontExtents -- cairo_font_extentsGet the font extents

Description

Object oriented style (method):

public CairoContext::fontExtents ( void ) : array

Procedural style:

cairo_font_extents ( CairoContext $context ) : array

Gets the font extents for the currently selected font.

Parameters

context

Description...

Return Values

An array containing the font extents for the current font.

Examples

Example #1 Object oriented style

<?php

$sur 
= new CairoImageSurface(CairoFormat::ARGB325050);
$con = new CairoContext($sur);

var_dump($con->fontExtents());

?>

The above example will output something similar to:

   array(5) {
     ["ascent"]=>
     float(10)
     ["descent"]=>
     float(3)
     ["height"]=>
     float(13.3125)
     ["max_x_advance"]=>
     float(26.65625)
     ["max_y_advance"]=>
     float(0)
   }
   

Example #2 Procedural style

<?php

$sur 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);
$con cairo_create($sur);

var_dump(cairo_font_extents($con));

?>

The above example will output something similar to:

   array(5) {
     ["ascent"]=>
     float(10)
     ["descent"]=>
     float(3)
     ["height"]=>
     float(13.3125)
     ["max_x_advance"]=>
     float(26.65625)
     ["max_y_advance"]=>
     float(0)
   }
   

See Also

  • Classname::Method()



CairoContext::getAntialias

cairo_get_antialias

(PECL cairo >= 0.1.0)

CairoContext::getAntialias -- cairo_get_antialiasRetrieves the current antialias mode

Description

Object oriented style (method):

public CairoContext::getAntialias ( void ) : int

Procedural style:

cairo_get_antialias ( CairoContext $context ) : int

Returns the current CairoAntialias mode, as set by CairoContext::setAntialias().

Parameters

context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Return Values

The current CairoAntialias mode.

Examples

Example #1 Object oriented style

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);
$context = new CairoContext($surface);

$context->setAntialias(CairoAntialias::MODE_SUBPIXEL);

var_dump($context->getAntialias());

?>

The above example will output something similar to:

   int(3)
   

Example #2 Procedural style

<?php

$sur 
cairo_image_surface_create(CAIRO_FORMAT_ARGB325050);
$con cairo_create($sur);

cairo_set_antialias($conCAIRO_ANTIALIAS_SUBPIXEL);

var_dump(cairo_get_antialias($con));

?>

The above example will output something similar to:

   int(3)
   

See Also



CairoContext::getCurrentPoint

cairo_get_current_point

(PECL cairo >= 0.1.0)

CairoContext::getCurrentPoint -- cairo_get_current_pointThe getCurrentPoint purpose

Description

Object oriented style

public CairoContext::getCurrentPoint ( void ) : array

Procedural style

cairo_get_current_point ( CairoContext $context ) : array

Gets the current point of the current path, which is conceptually the final point reached by the path so far.

The current point is returned in the user-space coordinate system. If there is no defined current point or if cr is in an error status, x and y will both be set to 0.0. It is possible to check this in advance with CairoContext::hasCurrentPoint().

Most path construction functions alter the current point. See the following for details on how they affect the current point: CairoContext::newPath(), CairoContext::newSubPath(), CairoContext::appendPath(), CairoContext::closePath(), CairoContext::moveTo(), CairoContext::lineTo(), CairoContext::curveTo(), CairoContext::relMoveTo(), CairoContext::relLineTo(), CairoContext::relCurveTo(), CairoContext::arc(), CairoContext::arcNegative(), CairoContext::rectangle(), CairoContext::textPath(), CairoContext::glyphPath().

Some functions use and alter the current point but do not otherwise change current path: CairoContext::showText().

Some functions unset the current path and as a result, current point: CairoContext::fill(), CairoContext::stroke().

Parameters

context

A valid CairoContext object.

Return Values

An array containing the x (index 0) and y (index 1) coordinates of the current point.

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

$c->moveTo(1010);

var_dump($c->getCurrentPoint());

?>

The above example will output something similar to:

   array(2) {
     [0]=>
     float(10)
     [1]=>
     float(10)
   }
   

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_move_to($c1010);

var_dump(cairo_get_current_point($c));

?>

The above example will output something similar to:

   array(2) {
     [0]=>
     float(10)
     [1]=>
     float(10)
   }
   

See Also



CairoContext::getDash

cairo_get_dash

(PECL cairo >= 0.1.0)

CairoContext::getDash -- cairo_get_dashThe getDash purpose

Description

Object oriented style (method):

public CairoContext::getDash ( void ) : array

Procedural style:

cairo_get_dash ( CairoContext $context ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getDashCount

cairo_get_dash_count

(PECL cairo >= 0.1.0)

CairoContext::getDashCount -- cairo_get_dash_countThe getDashCount purpose

Description

Object oriented style (method):

public CairoContext::getDashCount ( void ) : int

Procedural style:

cairo_get_dash_count ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getFillRule

cairo_get_fill_rule

(PECL cairo >= 0.1.0)

CairoContext::getFillRule -- cairo_get_fill_ruleThe getFillRule purpose

Description

Object oriented style (method):

public CairoContext::getFillRule ( void ) : int

Procedural style:

cairo_get_fill_rule ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getFontFace

cairo_get_font_face

(PECL cairo >= 0.1.0)

CairoContext::getFontFace -- cairo_get_font_faceThe getFontFace purpose

Description

Object oriented style (method):

public CairoContext::getFontFace ( void ) : void

Procedural style:

cairo_get_font_face ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getFontMatrix

cairo_get_font_matrix

(PECL cairo >= 0.1.0)

CairoContext::getFontMatrix -- cairo_get_font_matrixThe getFontMatrix purpose

Description

Object oriented style (method):

public CairoContext::getFontMatrix ( void ) : void

Procedural style:

cairo_get_font_matrix ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getFontOptions

cairo_get_font_options

(PECL cairo >= 0.1.0)

CairoContext::getFontOptions -- cairo_get_font_optionsThe getFontOptions purpose

Description

Object oriented style (method):

public CairoContext::getFontOptions ( void ) : void

Procedural style:

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getGroupTarget

cairo_get_group_target

(PECL cairo >= 0.1.0)

CairoContext::getGroupTarget -- cairo_get_group_targetThe getGroupTarget purpose

Description

Object oriented style (method):

public CairoContext::getGroupTarget ( void ) : void

Procedural style:

cairo_get_group_target ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getLineCap

cairo_get_line_cap

(PECL cairo >= 0.1.0)

CairoContext::getLineCap -- cairo_get_line_capThe getLineCap purpose

Description

Object oriented style (method):

public CairoContext::getLineCap ( void ) : int

Procedural style:

cairo_get_line_cap ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getLineJoin

cairo_get_line_join

(PECL cairo >= 0.1.0)

CairoContext::getLineJoin -- cairo_get_line_joinThe getLineJoin purpose

Description

Object oriented style (method):

public CairoContext::getLineJoin ( void ) : int

Procedural style:

cairo_get_line_join ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getLineWidth

cairo_get_line_width

(PECL cairo >= 0.1.0)

CairoContext::getLineWidth -- cairo_get_line_widthThe getLineWidth purpose

Description

Object oriented style (method):

public CairoContext::getLineWidth ( void ) : float

Procedural style:

cairo_get_line_width ( CairoContext $context ) : float

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getMatrix

cairo_get_matrix

(PECL cairo >= 0.1.0)

CairoContext::getMatrix -- cairo_get_matrixThe getMatrix purpose

Description

Object oriented style (method):

public CairoContext::getMatrix ( void ) : void

Procedural style:

cairo_get_matrix ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getMiterLimit

cairo_get_miter_limit

(PECL cairo >= 0.1.0)

CairoContext::getMiterLimit -- cairo_get_miter_limitThe getMiterLimit purpose

Description

Object oriented style (method):

public CairoContext::getMiterLimit ( void ) : float

Procedural style:

cairo_get_miter_limit ( CairoContext $context ) : float

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getOperator

cairo_get_operator

(PECL cairo >= 0.1.0)

CairoContext::getOperator -- cairo_get_operatorThe getOperator purpose

Description

Object oriented style (method):

public CairoContext::getOperator ( void ) : int

Procedural style:

cairo_get_operator ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getScaledFont

cairo_get_scaled_font

(PECL cairo >= 0.1.0)

CairoContext::getScaledFont -- cairo_get_scaled_fontThe getScaledFont purpose

Description

Object oriented style (method):

public CairoContext::getScaledFont ( void ) : void

Procedural style:

cairo_get_scaled_font ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getSource

cairo_get_source

(PECL cairo >= 0.1.0)

CairoContext::getSource -- cairo_get_sourceThe getSource purpose

Description

Object oriented style (method):

public CairoContext::getSource ( void ) : void

Procedural style:

cairo_get_source ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getTarget

cairo_get_target

(PECL cairo >= 0.1.0)

CairoContext::getTarget -- cairo_get_targetThe getTarget purpose

Description

Object oriented style (method):

public CairoContext::getTarget ( void ) : void

Procedural style:

cairo_get_target ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::getTolerance

cairo_get_tolerance

(PECL cairo >= 0.1.0)

CairoContext::getTolerance -- cairo_get_toleranceThe getTolerance purpose

Description

Object oriented style (method):

public CairoContext::getTolerance ( void ) : float

Procedural style:

cairo_get_tolerance ( CairoContext $context ) : float

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::glyphPath

cairo_glyph_path

(PECL cairo >= 0.1.0)

CairoContext::glyphPath -- cairo_glyph_pathThe glyphPath purpose

Description

Object oriented style

public CairoContext::glyphPath ( array $glyphs ) : void

Procedural style

cairo_glyph_path ( CairoContext $context , array $glyphs ) : void

Adds closed paths for the glyphs to the current path. The generated path if filled, achieves an effect similar to that of CairoContext::showGlyphs().

Parameters

context

A CairoContext object

glyphs

Array of glyphs

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   



CairoContext::hasCurrentPoint

cairo_has_current_point

(PECL cairo >= 0.1.0)

CairoContext::hasCurrentPoint -- cairo_has_current_pointThe hasCurrentPoint purpose

Description

Object oriented style (method):

public CairoContext::hasCurrentPoint ( void ) : bool

Procedural style:

cairo_has_current_point ( CairoContext $context ) : bool

Returns whether a current point is defined on the current path. See CairoContext::getCurrentPoint() for details on the current point.

Parameters

context

A valid CairoContext object.

Return Values

Whether a current point is defined

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

var_dump($c->hasCurrentPoint());

$c->moveTo(1010);

var_dump($c->hasCurrentPoint());

?>

The above example will output:

   bool(false)
   bool(true)
   

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

var_dump(cairo_has_current_point($c));

cairo_move_to($c1010);

var_dump(cairo_has_current_point($c));

?>

The above example will output:

   bool(false)
   bool(true)
   

See Also



CairoContext::identityMatrix

cairo_identity_matrix

(PECL cairo >= 0.1.0)

CairoContext::identityMatrix -- cairo_identity_matrixThe identityMatrix purpose

Description

Object oriented style (method):

public CairoContext::identityMatrix ( void ) : void

Procedural style:

cairo_identity_matrix ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::inFill

cairo_in_fill

(PECL cairo >= 0.1.0)

CairoContext::inFill -- cairo_in_fillThe inFill purpose

Description

Object oriented style (method):

public CairoContext::inFill ( float $x , float $y ) : bool

Procedural style:

cairo_in_fill ( CairoContext $context , float $x , float $y ) : bool

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::inStroke

cairo_in_stroke

(PECL cairo >= 0.1.0)

CairoContext::inStroke -- cairo_in_strokeThe inStroke purpose

Description

Object oriented style (method):

public CairoContext::inStroke ( float $x , float $y ) : bool

Procedural style:

cairo_in_stroke ( CairoContext $context , float $x , float $y ) : bool

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::lineTo

cairo_line_to

(PECL cairo >= 0.1.0)

CairoContext::lineTo -- cairo_line_toThe lineTo purpose

Description

Object oriented style (method):

public CairoContext::lineTo ( float $x , float $y ) : void

Procedural style:

cairo_line_to ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::mask

cairo_mask

(PECL cairo >= 0.1.0)

CairoContext::mask -- cairo_maskThe mask purpose

Description

Object oriented style (method):

public CairoContext::mask ( CairoPattern $pattern ) : void

Procedural style:

cairo_mask ( CairoContext $context , CairoPattern $pattern ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

pattern

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::maskSurface

cairo_mask_surface

(PECL cairo >= 0.1.0)

CairoContext::maskSurface -- cairo_mask_surfaceThe maskSurface purpose

Description

Object oriented style (method):

public CairoContext::maskSurface ( CairoSurface $surface [, float $x [, float $y ]] ) : void

Procedural style:

cairo_mask_surface ( CairoContext $context , CairoSurface $surface [, float $x [, float $y ]] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

surface

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::moveTo

cairo_move_to

(PECL cairo >= 0.1.0)

CairoContext::moveTo -- cairo_move_toThe moveTo purpose

Description

Object oriented style (method):

public CairoContext::moveTo ( float $x , float $y ) : void

Procedural style:

cairo_move_to ( CairoContext $context , float $x , float $y ) : void

Begin a new sub-path. After this call the current point will be (x, y).

Parameters

context

A valid CairoContext object.

x

The x coordinate of the new position.

y

The y coordinate of the new position

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php

$s 
= new CairoImageSurface(CairoFormat::ARGB32100100);
$c = new CairoContext($s);

$c->setSourceRgb(000);
$c->paint();

// Move 10 pixels across, and 10 pixels down
$c->moveTo(1010);
$c->lineTo(9090);
$c->setLineWidth(2);
$c->setSourceRgb(111);
$c->stroke();

// Move 90 pixels across, and 10 pixels down
$c->moveTo(9010);
$c->lineTo(1090);
$c->setLineWidth(2);
$c->setSourceRgb(111);
$c->stroke();

$s->writeToPng(dirname(__FILE__) . '/CairoContext_moveTo.png');
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php

$s 
cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE100100);
$c cairo_create($s);

cairo_set_source_rgb($c000);
cairo_paint($c);

// Move 10 pixels across, and 10 pixels down
cairo_move_to($c1010);
cairo_line_to($c9090);
cairo_set_line_width($c2);
cairo_set_source_rgb($c111);
cairo_stroke($c);

// Move 90 pixels across, and 10 pixels down
cairo_move_to($c9010);
cairo_line_to($c1090);
cairo_set_line_width($c2);
cairo_set_source_rgb($c111);
cairo_stroke($c);

cairo_surface_write_to_png($sdirname(__FILE__) . '/cairo_move_to.png');
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::newPath

cairo_new_path

(PECL cairo >= 0.1.0)

CairoContext::newPath -- cairo_new_pathThe newPath purpose

Description

Object oriented style (method):

public CairoContext::newPath ( void ) : void

Procedural style:

cairo_new_path ( CairoContext $context ) : void

Clears the current path. After this call there will be no path and no current point.

Parameters

context

A valid CairoContext object.

Return Values

No value is returned.

Examples

Example #1 Object oriented style

<?php
// [...]
CairoContext::newPath();
?>

Example #2 Procedural style

<?php
// [...]
cairo_new_path($context);
?>

See Also



CairoContext::newSubPath

cairo_new_sub_path

(PECL cairo >= 0.1.0)

CairoContext::newSubPath -- cairo_new_sub_pathThe newSubPath purpose

Description

Object oriented style (method):

public CairoContext::newSubPath ( void ) : void

Procedural style:

cairo_new_sub_path ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::paint

cairo_paint

(PECL cairo >= 0.1.0)

CairoContext::paint -- cairo_paintThe paint purpose

Description

Object oriented style (method):

public CairoContext::paint ( void ) : void

Procedural style:

cairo_paint ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::paintWithAlpha

cairo_paint_with_alpha

(PECL cairo >= 0.1.0)

CairoContext::paintWithAlpha -- cairo_paint_with_alphaThe paintWithAlpha purpose

Description

Object oriented style (method):

public CairoContext::paintWithAlpha ( float $alpha ) : void

Procedural style:

cairo_paint_with_alpha ( CairoContext $context , float $alpha ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

alpha

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::pathExtents

cairo_path_extents

(PECL cairo >= 0.1.0)

CairoContext::pathExtents -- cairo_path_extentsThe pathExtents purpose

Description

Object oriented style (method):

public CairoContext::pathExtents ( void ) : array

Procedural style:

cairo_path_extents ( CairoContext $context ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::popGroup

cairo_pop_group

(PECL cairo >= 0.1.0)

CairoContext::popGroup -- cairo_pop_groupThe popGroup purpose

Description

Object oriented style (method):

public CairoContext::popGroup ( void ) : void

Procedural style:

cairo_pop_group ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::popGroupToSource

cairo_pop_group_to_source

(PECL cairo >= 0.1.0)

CairoContext::popGroupToSource -- cairo_pop_group_to_sourceThe popGroupToSource purpose

Description

Object oriented style (method):

public CairoContext::popGroupToSource ( void ) : void

Procedural style:

cairo_pop_group_to_source ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::pushGroup

cairo_push_group

(PECL cairo >= 0.1.0)

CairoContext::pushGroup -- cairo_push_groupThe pushGroup purpose

Description

Object oriented style (method):

public CairoContext::pushGroup ( void ) : void

Procedural style:

cairo_push_group ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::pushGroupWithContent

cairo_push_group_with_content

(PECL cairo >= 0.1.0)

CairoContext::pushGroupWithContent -- cairo_push_group_with_contentThe pushGroupWithContent purpose

Description

Object oriented style (method):

public CairoContext::pushGroupWithContent ( int $content ) : void

Procedural style:

cairo_push_group_with_content ( CairoContext $context , int $content ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

content

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::rectangle

cairo_rectangle

(PECL cairo >= 0.1.0)

CairoContext::rectangle -- cairo_rectangleThe rectangle purpose

Description

Object oriented style (method):

public CairoContext::rectangle ( float $x , float $y , float $width , float $height ) : void

Procedural style:

cairo_rectangle ( CairoContext $context , float $x , float $y , float $width , float $height ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::relCurveTo

cairo_rel_curve_to

(PECL cairo >= 0.1.0)

CairoContext::relCurveTo -- cairo_rel_curve_toThe relCurveTo purpose

Description

Object oriented style (method):

public CairoContext::relCurveTo ( float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void

Procedural style:

cairo_rel_curve_to ( CairoContext $context , float $x1 , float $y1 , float $x2 , float $y2 , float $x3 , float $y3 ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x1

Description...

y1

Description...

x2

Description...

y2

Description...

x3

Description...

y3

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::relLineTo

cairo_rel_line_to

(PECL cairo >= 0.1.0)

CairoContext::relLineTo -- cairo_rel_line_toThe relLineTo purpose

Description

Object oriented style (method):

public CairoContext::relLineTo ( float $x , float $y ) : void

Procedural style:

cairo_rel_line_to ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::relMoveTo

cairo_rel_move_to

(PECL cairo >= 0.1.0)

CairoContext::relMoveTo -- cairo_rel_move_toThe relMoveTo purpose

Description

Object oriented style (method):

public CairoContext::relMoveTo ( float $x , float $y ) : void

Procedural style:

cairo_rel_move_to ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::resetClip

cairo_reset_clip

(PECL cairo >= 0.1.0)

CairoContext::resetClip -- cairo_reset_clipThe resetClip purpose

Description

Object oriented style (method):

public CairoContext::resetClip ( void ) : void

Procedural style:

cairo_reset_clip ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::restore

cairo_restore

(PECL cairo >= 0.1.0)

CairoContext::restore -- cairo_restoreThe restore purpose

Description

Object oriented style (method):

public CairoContext::restore ( void ) : void

Procedural style:

cairo_restore ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::rotate

cairo_rotate

(PECL cairo >= 0.1.0)

CairoContext::rotate -- cairo_rotateThe rotate purpose

Description

Object oriented style (method):

public CairoContext::rotate ( float $angle ) : void

Procedural style:

cairo_rotate ( CairoContext $context , float $angle ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

angle

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::save

cairo_save

(PECL cairo >= 0.1.0)

CairoContext::save -- cairo_saveThe save purpose

Description

Object oriented style (method):

public CairoContext::save ( void ) : void

Procedural style:

cairo_save ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::scale

cairo_scale

(PECL cairo >= 0.1.0)

CairoContext::scale -- cairo_scaleThe scale purpose

Description

Object oriented style (method):

public CairoContext::scale ( float $x , float $y ) : void

Procedural style:

cairo_scale ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::selectFontFace

cairo_select_font_face

(PECL cairo >= 0.1.0)

CairoContext::selectFontFace -- cairo_select_font_faceThe selectFontFace purpose

Description

Object oriented style (method):

public CairoContext::selectFontFace ( string $family [, int $slant [, int $weight ]] ) : void

Procedural style:

cairo_select_font_face ( CairoContext $context , string $family [, int $slant [, int $weight ]] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

family

Description...

slant

Description...

weight

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setAntialias

cairo_set_antialias

(PECL cairo >= 0.1.0)

CairoContext::setAntialias -- cairo_set_antialiasThe setAntialias purpose

Description

Object oriented style (method):

public CairoContext::setAntialias ([ int $antialias ] ) : void

Procedural style:

cairo_set_antialias ( CairoContext $context [, int $antialias ] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

antialias

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setDash

cairo_set_dash

(PECL cairo >= 0.1.0)

CairoContext::setDash -- cairo_set_dashThe setDash purpose

Description

Object oriented style (method):

public CairoContext::setDash ( array $dashes [, float $offset ] ) : void

Procedural style:

cairo_set_dash ( CairoContext $context , array $dashes [, float $offset ] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

dashes

Description...

offset

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setFillRule

cairo_set_fill_rule

(PECL cairo >= 0.1.0)

CairoContext::setFillRule -- cairo_set_fill_ruleThe setFillRule purpose

Description

Object oriented style (method):

public CairoContext::setFillRule ( int $setting ) : void

Procedural style:

cairo_set_fill_rule ( CairoContext $context , int $setting ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

setting

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setFontFace

cairo_set_font_face

(PECL cairo >= 0.1.0)

CairoContext::setFontFace -- cairo_set_font_faceThe setFontFace purpose

Description

Object oriented style (method):

public CairoContext::setFontFace ( CairoFontFace $fontface ) : void

Procedural style:

cairo_set_font_face ( CairoContext $context , CairoFontFace $fontface ) : void

Sets the font-face for a given context.

Parameters

context

A CairoContext object to change the font-face for.

fontface

A CairoFontFace object

Return Values

No value is returned

Examples

Example #1 Object oriented style

<?php
// New surface with white background
$s = new CairoImageSurface(CairoFormat::ARGB32300100);
$c = new CairoContext($s);
$c->setSourceRgb(111);
$c->paint();

// Draw some text
$c->setSourceRgb(000);
$c->moveTo(1060);
// Create a new font face
$f = new CairoToyFontFace("sans-serif"CairoFontSlant::NORMALCairoFontWeight::NORMAL);
$c->setFontFace($f);
$c->setFontSize(30);
$c->showText('Hello, World!');
$s->writeToPng(dirname(__FILE__) . '/setFontFace.png');
?>

Example #2 Procedural style

<?php
/* ... */
?>

See Also



CairoContext::setFontMatrix

cairo_set_font_matrix

(PECL cairo >= 0.1.0)

CairoContext::setFontMatrix -- cairo_set_font_matrixThe setFontMatrix purpose

Description

Object oriented style (method):

public CairoContext::setFontMatrix ( CairoMatrix $matrix ) : void

Procedural style:

cairo_set_font_matrix ( CairoContext $context , CairoMatrix $matrix ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

matrix

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setFontOptions

cairo_set_font_options

(PECL cairo >= 0.1.0)

CairoContext::setFontOptions -- cairo_set_font_optionsThe setFontOptions purpose

Description

Object oriented style (method):

public CairoContext::setFontOptions ( CairoFontOptions $fontoptions ) : void

Procedural style:

cairo_set_font_options ( CairoContext $context , CairoFontOptions $fontoptions ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

fontoptions

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setFontSize

cairo_set_font_size

(PECL cairo >= 0.1.0)

CairoContext::setFontSize -- cairo_set_font_sizeThe setFontSize purpose

Description

Object oriented style (method):

public CairoContext::setFontSize ( float $size ) : void

Procedural style:

cairo_set_font_size ( CairoContext $context , float $size ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

size

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setLineCap

cairo_set_line_cap

(PECL cairo >= 0.1.0)

CairoContext::setLineCap -- cairo_set_line_capThe setLineCap purpose

Description

Object oriented style (method):

public CairoContext::setLineCap ( int $setting ) : void

Procedural style:

cairo_set_line_cap ( CairoContext $context , int $setting ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

setting

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setLineJoin

cairo_set_line_join

(PECL cairo >= 0.1.0)

CairoContext::setLineJoin -- cairo_set_line_joinThe setLineJoin purpose

Description

Object oriented style (method):

public CairoContext::setLineJoin ( int $setting ) : void

Procedural style:

cairo_set_line_join ( CairoContext $context , int $setting ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

setting

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setLineWidth

cairo_set_line_width

(PECL cairo >= 0.1.0)

CairoContext::setLineWidth -- cairo_set_line_widthThe setLineWidth purpose

Description

Object oriented style (method):

public CairoContext::setLineWidth ( float $width ) : void

Procedural style:

cairo_set_line_width ( CairoContext $context , float $width ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

width

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setMatrix

cairo_set_matrix

(PECL cairo >= 0.1.0)

CairoContext::setMatrix -- cairo_set_matrixThe setMatrix purpose

Description

Object oriented style (method):

public CairoContext::setMatrix ( CairoMatrix $matrix ) : void

Procedural style:

cairo_set_matrix ( CairoContext $context , CairoMatrix $matrix ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

matrix

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setMiterLimit

cairo_set_miter_limit

(PECL cairo >= 0.1.0)

CairoContext::setMiterLimit -- cairo_set_miter_limitThe setMiterLimit purpose

Description

Object oriented style (method):

public CairoContext::setMiterLimit ( float $limit ) : void

Procedural style:

cairo_set_miter_limit ( CairoContext $context , float $limit ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

limit

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setOperator

cairo_set_operator

(PECL cairo >= 0.1.0)

CairoContext::setOperator -- cairo_set_operatorThe setOperator purpose

Description

Object oriented style (method):

public CairoContext::setOperator ( int $setting ) : void

Procedural style:

cairo_set_operator ( CairoContext $context , int $setting ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

setting

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setScaledFont

cairo_set_scaled_font

(PECL cairo >= 0.1.0)

CairoContext::setScaledFont -- cairo_set_scaled_fontThe setScaledFont purpose

Description

Object oriented style (method):

public CairoContext::setScaledFont ( CairoScaledFont $scaledfont ) : void

Procedural style:

cairo_set_scaled_font ( CairoContext $context , CairoScaledFont $scaledfont ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

scaledfont

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setSource

cairo_set_source

(PECL cairo >= 0.1.0)

CairoContext::setSource -- cairo_set_sourceThe setSource purpose

Description

Object oriented style (method):

public CairoContext::setSource ( CairoPattern $pattern ) : void

Procedural style:

cairo_set_source ( CairoContext $context , CairoPattern $pattern ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

pattern

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setSourceRGB

cairo_set_source

(PECL cairo >= 0.1.0)

CairoContext::setSourceRGB -- cairo_set_sourceThe setSourceRGB purpose

Description

Object oriented style (method):

public CairoContext::setSourceRGB ( float $red , float $green , float $blue ) : void

Procedural style:

cairo_set_source ( CairoContext $context , float $red , float $green , float $blue ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

red

Description...

green

Description...

blue

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setSourceRGBA

cairo_set_source

(PECL cairo >= 0.1.0)

CairoContext::setSourceRGBA -- cairo_set_sourceThe setSourceRGBA purpose

Description

Object oriented style (method):

public CairoContext::setSourceRGBA ( float $red , float $green , float $blue , float $alpha ) : void

Procedural style:

cairo_set_source ( CairoContext $context , float $red , float $green , float $blue , float $alpha ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

red

Description...

green

Description...

blue

Description...

alpha

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setSourceSurface

cairo_set_source_surface

(PECL cairo >= 0.1.0)

CairoContext::setSourceSurface -- cairo_set_source_surfaceThe setSourceSurface purpose

Description

Object oriented style (method):

public CairoContext::setSourceSurface ( CairoSurface $surface [, float $x [, float $y ]] ) : void

Procedural style:

cairo_set_source_surface ( CairoContext $context , CairoSurface $surface [, float $x [, float $y ]] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

surface

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::setTolerance

cairo_set_tolerance

(PECL cairo >= 0.1.0)

CairoContext::setTolerance -- cairo_set_toleranceThe setTolerance purpose

Description

Object oriented style (method):

public CairoContext::setTolerance ( float $tolerance ) : void

Procedural style:

cairo_set_tolerance ( CairoContext $context , float $tolerance ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

tolerance

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::showPage

cairo_show_page

(PECL cairo >= 0.1.0)

CairoContext::showPage -- cairo_show_pageThe showPage purpose

Description

Object oriented style (method):

public CairoContext::showPage ( void ) : void

Procedural style:

cairo_show_page ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::showText

cairo_show_text

(PECL cairo >= 0.1.0)

CairoContext::showText -- cairo_show_textThe showText purpose

Description

Object oriented style (method):

public CairoContext::showText ( string $text ) : void

Procedural style:

cairo_show_text ( CairoContext $context , string $text ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

text

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::status

cairo_status

(PECL cairo >= 0.1.0)

CairoContext::status -- cairo_statusThe status purpose

Description

Object oriented style (method):

public CairoContext::status ( void ) : int

Procedural style:

cairo_status ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::stroke

cairo_stroke

(PECL cairo >= 0.1.0)

CairoContext::stroke -- cairo_strokeThe stroke purpose

Description

Object oriented style (method):

public CairoContext::stroke ( void ) : void

Procedural style:

cairo_stroke ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::strokeExtents

cairo_stroke_extents

(PECL cairo >= 0.1.0)

CairoContext::strokeExtents -- cairo_stroke_extentsThe strokeExtents purpose

Description

Object oriented style (method):

public CairoContext::strokeExtents ( void ) : array

Procedural style:

cairo_stroke_extents ( CairoContext $context ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::strokePreserve

cairo_stroke_preserve

(PECL cairo >= 0.1.0)

CairoContext::strokePreserve -- cairo_stroke_preserveThe strokePreserve purpose

Description

Object oriented style (method):

public CairoContext::strokePreserve ( void ) : void

Procedural style:

cairo_stroke_preserve ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::textExtents

cairo_text_extents

(PECL cairo >= 0.1.0)

CairoContext::textExtents -- cairo_text_extentsThe textExtents purpose

Description

Object oriented style (method):

public CairoContext::textExtents ( string $text ) : array

Procedural style:

cairo_text_extents ( CairoContext $context ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

text

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::textPath

cairo_text_path

(PECL cairo >= 0.1.0)

CairoContext::textPath -- cairo_text_pathThe textPath purpose

Description

Object oriented style

public CairoContext::textPath ( string $string ) : void

Procedural style

cairo_text_path ( CairoContext $context , string $text ) : void

Adds closed paths for text to the current path. The generated path, if filled, achieves an effect similar to that of CairoContext::showText().

Text conversion and positioning is done similar to CairoContext::showText().

Like CairoContext::showText(), after this call the current point is moved to the origin of where the next glyph would be placed in this same progression. That is, the current point will be at the origin of the final glyph offset by its advance values. This allows for chaining multiple calls to CairoContext::showText() without having to set current point in between.

Note: The CairoContext::textPath() function call is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, but it is not expected to be adequate for serious text-using applications. See CairoContext::glyphPath() for the "real" text path API in cairo.

Parameters

context

A CairoContext object

text

Description...

string

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::transform

cairo_transform

(PECL cairo >= 0.1.0)

CairoContext::transform -- cairo_transformThe transform purpose

Description

Object oriented style (method):

public CairoContext::transform ( CairoMatrix $matrix ) : void

Procedural style:

cairo_transform ( CairoContext $context , CairoMatrix $matrix ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

matrix

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::translate

cairo_translate

(PECL cairo >= 0.1.0)

CairoContext::translate -- cairo_translateThe translate purpose

Description

Object oriented style (method):

public CairoContext::translate ( float $x , float $y ) : void

Procedural style:

cairo_translate ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::userToDevice

cairo_user_to_device

(PECL cairo >= 0.1.0)

CairoContext::userToDevice -- cairo_user_to_deviceThe userToDevice purpose

Description

Object oriented style (method):

public CairoContext::userToDevice ( float $x , float $y ) : array

Procedural style:

cairo_user_to_device ( CairoContext $context , float $x , float $y ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoContext::userToDeviceDistance

cairo_user_to_device_distance

(PECL cairo >= 0.1.0)

CairoContext::userToDeviceDistance -- cairo_user_to_device_distanceThe userToDeviceDistance purpose

Description

Object oriented style (method):

public CairoContext::userToDeviceDistance ( float $x , float $y ) : array

Procedural style:

cairo_user_to_device_distance ( CairoContext $context , float $x , float $y ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoException class

(PECL cairo >= 0.1.0)

Introduction

Exception class thrown by Cairo functions and methods

Class synopsis

CairoException extends Exception {
/* Inherited properties */
protected string message ;
protected int code ;
protected string file ;
protected int line ;
/* Inherited methods */
final public Exception::getMessage ( void ) : string
final public Exception::getPrevious ( void ) : Throwable
final public Exception::getCode ( void ) : mixed
final public Exception::getFile ( void ) : string
final public Exception::getLine ( void ) : int
final public Exception::getTrace ( void ) : array
final public Exception::getTraceAsString ( void ) : string
public Exception::__toString ( void ) : string
final private Exception::__clone ( void ) : void
}


The CairoStatus class

(No version information available, might only be in Git)

Introduction

CairoStatus is used to indicate errors that can occur when using Cairo. In some cases it is returned directly by functions. but when using CairoContext, the last error, if any, is stored in the object and can be retrieved with CairoContext::status() or cairo_status(). New entries may be added in future versions.

Use Cairo::statusToString() or cairo_status_to_string() to get a human-readable representation of an error message.

Class synopsis

CairoStatus {
/* Constants */
const integer SUCCESS = 0 ;
const integer NO_MEMORY = 1 ;
const integer INVALID_RESTORE = 2 ;
const integer INVALID_POP_GROUP = 3 ;
const integer NO_CURRENT_POINT = 4 ;
const integer INVALID_MATRIX = 5 ;
const integer INVALID_STATUS = 6 ;
const integer NULL_POINTER = 7 ;
const integer INVALID_STRING = 8 ;
const integer INVALID_PATH_DATA = 9 ;
const integer READ_ERROR = 10 ;
const integer WRITE_ERROR = 11 ;
const integer SURFACE_FINISHED = 12 ;
const integer SURFACE_TYPE_MISMATCH = 13 ;
const integer PATTERN_TYPE_MISMATCH = 14 ;
const integer INVALID_CONTENT = 15 ;
const integer INVALID_FORMAT = 16 ;
const integer INVALID_VISUAL = 17 ;
const integer FILE_NOT_FOUND = 18 ;
const integer INVALID_DASH = 19 ;
const integer INVALID_DSC_COMMENT = 20 ;
const integer INVALID_INDEX = 21 ;
const integer CLIP_NOT_REPRESENTABLE = 22 ;
const integer TEMP_FILE_ERROR = 23 ;
const integer INVALID_STRIDE = 24 ;
}

Predefined Constants

CairoStatus::SUCCESS

No error has occurred

CairoStatus::NO_MEMORY

Out of memory

CairoStatus::INVALID_RESTORE

cairo_restore() called without matching cairo_save()

CairoStatus::INVALID_POP_GROUP

No saved group to pop

CairoStatus::NO_CURRENT_POINT

No current point defined

CairoStatus::INVALID_MATRIX

Invalid matrix (not invertible)

CairoStatus::INVALID_STATUS

Invalid value for an input CairoStatus>

CairoStatus::NULL_POINTER

Null pointer

CairoStatus::INVALID_STRING

Input string not valid UTF-8 string

CairoStatus::INVALID_PATH_DATA

Input path data not valid

CairoStatus::READ_ERROR

Error while reading from input stream

CairoStatus::WRITE_ERROR

Error while writing to output stream

CairoStatus::SURFACE_FINISHED

Target surface has been finished

CairoStatus::SURFACE_TYPE_MISMATCH

The surface type is not appropriate for the operation

CairoStatus::PATTERN_TYPE_MISMATCH

The pattern type is not appropriate for the operation

CairoStatus::INVALID_CONTENT

Invalid value for an input CairoContent

CairoStatus::INVALID_FORMAT

Invalid value for an input CairoFormat

CairoStatus::INVALID_VISUAL

Invalid value for an input Visual

CairoStatus::FILE_NOT_FOUND

File not found

CairoStatus::INVALID_DASH

Invalid value for a dash setting

CairoStatus::INVALID_DSC_COMMENT

Invalid value for a DSC comment

CairoStatus::INVALID_INDEX

Invalid index passed to getter

CairoStatus::CLIP_NOT_REPRESENTABLE

Clip region not representable in desired format

CairoStatus::TEMP_FILE_ERROR

Error creating or writing to a temporary file

CairoStatus::INVALID_STRIDE

Invalid value for CairoStride



The CairoSurface class

(PECL cairo >= 0.1.0)

Introduction

This is the base-class for all other Surface types. CairoSurface is the abstract type representing all different drawing targets that cairo can render to. The actual drawings are performed using a CairoContext.

Class synopsis

CairoSurface {
/* Methods */
public __construct ( void )
public copyPage ( void ) : void
public createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void
public finish ( void ) : void
public flush ( void ) : void
public getContent ( void ) : int
public getDeviceOffset ( void ) : array
public getFontOptions ( void ) : void
public getType ( void ) : int
public markDirty ( void ) : void
public markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void
public setDeviceOffset ( float $x , float $y ) : void
public setFallbackResolution ( float $x , float $y ) : void
public showPage ( void ) : void
public status ( void ) : int
public writeToPng ( string $file ) : void
}

CairoSurface::__construct

(PECL cairo >= 0.1.0)

CairoSurface::__constructThe __construct purpose

Description

public CairoSurface::__construct ( void )

CairoSurface is an abstract type and, as such, should not be instantiated in your PHP scripts.

Parameters

This function has no parameters.

Return Values

No return value

Notes

Note:

If you're using a PHP version before 5.3, you must destroy the CairoContext associated with a CairoSurface after you destroy the CairoSurface. Otherwise, you're left with a Circular-reference memory leak.

See Also



CairoSurface::copyPage

cairo_copy_page

(PECL cairo >= 0.1.0)

CairoSurface::copyPage -- cairo_copy_pageThe copyPage purpose

Description

Object oriented style (method):

public CairoSurface::copyPage ( void ) : void

Procedural style:

cairo_copy_page ( CairoContext $context ) : void

Emits the current page for backends that support multiple pages, but doesn't clear it, so that the contents of the current page will be retained for the next page. Use CairoSurface::showPage() if you want to get an empty page after the emission.

Parameters

context

A CairoContext object

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::createSimilar

(PECL cairo >= 0.1.0)

CairoSurface::createSimilarThe createSimilar purpose

Description

public CairoSurface::createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void

Create a new surface that is as compatible as possible with an existing surface. For example the new surface will have the same fallback resolution and font options as other. Generally, the new surface will also use the same backend as other, unless that is not possible for some reason. The type of the returned surface may be examined with CairoSurface::getType(). Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)

Parameters

other

An existing surface used to select the backend of the new surface

content

The content for the new surface. See the CairoContent class for possible values.

width

Width of the new surface, (in device-space units).

height

Height of the new surface, (in device-space units).

Return Values

A new CairoSurface

Examples

Example #1 CairoSurface::createSimilar() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • CairoContent()



CairoSurface::finish

(PECL cairo >= 0.1.0)

CairoSurface::finishThe finish purpose

Description

public CairoSurface::finish ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::finish() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::flush

(PECL cairo >= 0.1.0)

CairoSurface::flushThe flush purpose

Description

public CairoSurface::flush ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::flush() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::getContent

(PECL cairo >= 0.1.0)

CairoSurface::getContentThe getContent purpose

Description

public CairoSurface::getContent ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::getContent() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::getDeviceOffset

(PECL cairo >= 0.1.0)

CairoSurface::getDeviceOffsetThe getDeviceOffset purpose

Description

public CairoSurface::getDeviceOffset ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::getDeviceOffset() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::getFontOptions

cairo_get_font_options

(PECL cairo >= 0.1.0)

CairoSurface::getFontOptions -- cairo_get_font_optionsThe getFontOptions purpose

Description

Object oriented style (method):

public CairoSurface::getFontOptions ( void ) : void

Procedural style:

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::getType

(PECL cairo >= 0.1.0)

CairoSurface::getTypeThe getType purpose

Description

public CairoSurface::getType ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::getType() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::markDirty

(PECL cairo >= 0.1.0)

CairoSurface::markDirtyThe markDirty purpose

Description

public CairoSurface::markDirty ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurface::markDirty() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::markDirtyRectangle

(PECL cairo >= 0.1.0)

CairoSurface::markDirtyRectangleThe markDirtyRectangle purpose

Description

public CairoSurface::markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x

Description...

y

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoSurface::markDirtyRectangle() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::setDeviceOffset

(PECL cairo >= 0.1.0)

CairoSurface::setDeviceOffsetThe setDeviceOffset purpose

Description

public CairoSurface::setDeviceOffset ( float $x , float $y ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 CairoSurface::setDeviceOffset() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::setFallbackResolution

(PECL cairo >= 0.1.0)

CairoSurface::setFallbackResolutionThe setFallbackResolution purpose

Description

public CairoSurface::setFallbackResolution ( float $x , float $y ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x

Description...

y

Description...

Return Values

Description...

Examples

Example #1 CairoSurface::setFallbackResolution() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::showPage

cairo_show_page

(PECL cairo >= 0.1.0)

CairoSurface::showPage -- cairo_show_pageThe showPage purpose

Description

Object oriented style (method):

public CairoSurface::showPage ( void ) : void

Procedural style:

cairo_show_page ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::status

cairo_status

(PECL cairo >= 0.1.0)

CairoSurface::status -- cairo_statusThe status purpose

Description

Object oriented style (method):

public CairoSurface::status ( void ) : int

Procedural style:

cairo_status ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurface::writeToPng

(PECL cairo >= 0.1.0)

CairoSurface::writeToPngThe writeToPng purpose

Description

public CairoSurface::writeToPng ( string $file ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

Return Values

Description...

Examples

Example #1 CairoSurface::writeToPng() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



Svg Surface Backend

(PECL cairo >= 0.1.0)

Introduction

Svg specific surface class, uses the SVG (standard vector graphics) surface backend.

Class synopsis

CairoSvgSurface extends CairoSurface {
/* Methods */
public __construct ( string $file , float $width , float $height )
public static getVersions ( void ) : array
public restrictToVersion ( int $version ) : void
public static versionToString ( int $version ) : string
/* Inherited methods */
public CairoSurface::__construct ( void )
public CairoSurface::copyPage ( void ) : void
public CairoSurface::createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void
public CairoSurface::finish ( void ) : void
public CairoSurface::flush ( void ) : void
public CairoSurface::getContent ( void ) : int
public CairoSurface::getDeviceOffset ( void ) : array
public CairoSurface::getFontOptions ( void ) : void
public CairoSurface::getType ( void ) : int
public CairoSurface::markDirty ( void ) : void
public CairoSurface::markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void
public CairoSurface::setDeviceOffset ( float $x , float $y ) : void
public CairoSurface::setFallbackResolution ( float $x , float $y ) : void
public CairoSurface::showPage ( void ) : void
public CairoSurface::status ( void ) : int
public CairoSurface::writeToPng ( string $file ) : void
}

CairoSvgSurface::__construct

(PECL cairo >= 0.1.0)

CairoSvgSurface::__constructThe __construct purpose

Description

public CairoSvgSurface::__construct ( string $file , float $width , float $height )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoSvgSurface::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSvgSurface::getVersions

cairo_svg_surface_get_versions

(PECL cairo >= 0.1.0)

CairoSvgSurface::getVersions -- cairo_svg_surface_get_versionsUsed to retrieve a list of supported SVG versions

Description

Object oriented style (method):

public static CairoSvgSurface::getVersions ( void ) : array

Procedural style:

cairo_svg_get_versions ( void ) : array

Returns a numerically indexed array of currently available CairoSvgVersion constants. In order to retrieve the string values for each item, use CairoSvgSurface::versionToString().

Parameters

This function has no parameters.

Return Values

Returns a numerically indexed array of integer values.

Examples

Example #1 CairoSvgSurface::getVersions() example

<?php
/* Grab our list of versions */
$versions CairoSvgSurface::getVersions();
var_dump($versions);

/* echo the string name of each version */
foreach($versions as $id) {
    echo 
CairoSvgSurface::versionToString($id), PHP_EOL;
}
?>

The above example will output something similar to:

   array(2) {
     [0]=>
     int(0)
     [1]=>
     int(1)
   }
   SVG 1.1
   SVG 1.2
   

Example #2 Procedural style

<?php
/* Grab our list of versions */
$versions cairo_svg_surface_get_versions();
var_dump($versions);

/* echo the string name of each version */
foreach($versions as $id) {
    echo 
cairo_svg_surface_version_to_string($id), PHP_EOL;
}
?>

The above example will output something similar to:

   array(2) {
     [0]=>
     int(0)
     [1]=>
     int(1)
   }
   SVG 1.1
   SVG 1.2
   

See Also



CairoSvgSurface::restrictToVersion

(PECL cairo >= 0.1.0)

CairoSvgSurface::restrictToVersionThe restrictToVersion purpose

Description

public CairoSvgSurface::restrictToVersion ( int $version ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

version

Description...

Return Values

Description...

Examples

Example #1 CairoSvgSurface::restrictToVersion() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSvgSurface::versionToString

(PECL cairo >= 0.1.0)

CairoSvgSurface::versionToStringThe versionToString purpose

Description

public static CairoSvgSurface::versionToString ( int $version ) : string

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

version

Description...

Return Values

Description...

Examples

Example #1 CairoSvgSurface::versionToString() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoImageSurface class

(PECL cairo >= 0.1.0)

Introduction

CairoImageSurface provide the ability to render to memory buffers either allocated by cairo or by the calling code. The supported image formats are those defined in CairoFormat.

Class synopsis

CairoImageSurface extends CairoSurface {
/* Methods */
public __construct ( int $format , int $width , int $height )
public static createForData ( string $data , int $format , int $width , int $height ) : void
public static createFromPng ( string $file ) : CairoImageSurface
public getData ( void ) : string
public getFormat ( void ) : int
public getHeight ( void ) : int
public getStride ( void ) : int
public getWidth ( void ) : int
/* Inherited methods */
public CairoSurface::__construct ( void )
public CairoSurface::copyPage ( void ) : void
public CairoSurface::createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void
public CairoSurface::finish ( void ) : void
public CairoSurface::flush ( void ) : void
public CairoSurface::getContent ( void ) : int
public CairoSurface::getDeviceOffset ( void ) : array
public CairoSurface::getFontOptions ( void ) : void
public CairoSurface::getType ( void ) : int
public CairoSurface::markDirty ( void ) : void
public CairoSurface::markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void
public CairoSurface::setDeviceOffset ( float $x , float $y ) : void
public CairoSurface::setFallbackResolution ( float $x , float $y ) : void
public CairoSurface::showPage ( void ) : void
public CairoSurface::status ( void ) : int
public CairoSurface::writeToPng ( string $file ) : void
}

CairoImageSurface::__construct

(PECL cairo >= 0.1.0)

CairoImageSurface::__constructCreates a new CairoImageSurface

Description

public CairoImageSurface::__construct ( int $format , int $width , int $height )

Creates a new CairoImageSuface object of type format

Parameters

format

Can be any defined in CairoFormat

width

The width of the image surface

height

The height of the image surface

Return Values

A new CairoImageSurface

Examples

Example #1 CairoImageSurface::__construct() example

<?php

// Creates a image with ARGB32 format of 50 width and 50 height
$surface = new CairoImageSurface(CairoFormat::ARGB3250,50);

?>

See Also



CairoImageSurface::createForData

(PECL cairo >= 0.1.0)

CairoImageSurface::createForDataThe createForData purpose

Description

public static CairoImageSurface::createForData ( string $data , int $format , int $width , int $height ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

data

Description...

format

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoImageSurface::createForData() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoImageSurface::createFromPng

(PECL cairo >= 0.1.0)

CairoImageSurface::createFromPngCreates a new CairoImageSurface form a png image file

Description

public static CairoImageSurface::createFromPng ( string $file ) : CairoImageSurface

Creates a new CairoImageSurface form a png image file

This method should be called static

Parameters

file

Path to PNG image file

Return Values

CairoImageSurface object

Examples

Example #1 CairoImageSurface::createFromPng() example

<?php

$surface 
CairoImageSurface::createFromPng('/path/to/image/file.png');

?>

The above example will output something similar to:

   ...
   

See Also



CairoImageSurface::getData

(PECL cairo >= 0.1.0)

CairoImageSurface::getDataGets the image data as string

Description

public CairoImageSurface::getData ( void ) : string

Returns the image data of this surface or NULL if surface is not an image surface, or if CairoContext::finish(), procedural : cairo_surface_finish(), has been called.

Parameters

This function has no parameters.

Return Values

The image data as string

Examples

Example #1 CairoImageSurface::getData() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also



CairoImageSurface::getFormat

(PECL cairo >= 0.1.0)

CairoImageSurface::getFormatGet the image format

Description

public CairoImageSurface::getFormat ( void ) : int

Retrieves the image format, as one of the CairoFormat defined

Parameters

This function has no parameters.

Return Values

One of the CairoFormat enums

Examples

Example #1 CairoImageSurface::getFormat() example

<?php

$surface 
= new CairoImageSurface(CairoFormat::ARGB325050);

var_dump($surface->getFormat()); // 0

$surface2 = new CairoImageSurface(CairoFormat::A85050);

var_dump($surface2->getFormat()); // 2

?>

The above example will output something similar to:

   int(0)
   int(2)
   

See Also



CairoImageSurface::getHeight

(PECL cairo >= 0.1.0)

CairoImageSurface::getHeightRetrieves the height of the CairoImageSurface

Description

public CairoImageSurface::getHeight ( void ) : int

This methods returns the CairoImageSurface height.

Parameters

This function has no parameters.

Return Values

CairoImageSurface object height

Examples

Example #1 CairoImageSurface::getHeight() example

<?php
// creates a new image surface
$surface = new CairoImageSurface(CairoFormat::ARGB328050);

//gets the height
var_dump($surface->getHeight());

?>

The above example will output something similar to:

   int(50)
   

See Also



CairoImageSurface::getStride

(PECL cairo >= 0.1.0)

CairoImageSurface::getStrideThe getStride purpose

Description

public CairoImageSurface::getStride ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoImageSurface::getStride() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoImageSurface::getWidth

(PECL cairo >= 0.1.0)

CairoImageSurface::getWidthRetrieves the width of the CairoImageSurface

Description

public CairoImageSurface::getWidth ( void ) : int

Gets the width of the CairoImageSurface

Parameters

This function has no parameters.

Return Values

Returns the width of the CairoImageSurface object

Examples

Example #1 CairoImageSurface::getWidth() example

<?php
// creates a new image surface
$surface = new CairoImageSurface(CairoFormat::ARGB328050);

//gets the width
var_dump($surface->getWidth());

?>

The above example will output something similar to:

   int(80)
   

See Also


Table of Contents



The CairoPdfSurface class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoPdfSurface extends CairoSurface {
/* Methods */
public __construct ( string $file , float $width , float $height )
public setSize ( float $width , float $height ) : void
/* Inherited methods */
public CairoSurface::__construct ( void )
public CairoSurface::copyPage ( void ) : void
public CairoSurface::createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void
public CairoSurface::finish ( void ) : void
public CairoSurface::flush ( void ) : void
public CairoSurface::getContent ( void ) : int
public CairoSurface::getDeviceOffset ( void ) : array
public CairoSurface::getFontOptions ( void ) : void
public CairoSurface::getType ( void ) : int
public CairoSurface::markDirty ( void ) : void
public CairoSurface::markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void
public CairoSurface::setDeviceOffset ( float $x , float $y ) : void
public CairoSurface::setFallbackResolution ( float $x , float $y ) : void
public CairoSurface::showPage ( void ) : void
public CairoSurface::status ( void ) : int
public CairoSurface::writeToPng ( string $file ) : void
}

CairoPdfSurface::__construct

(PECL cairo >= 0.1.0)

CairoPdfSurface::__constructThe __construct purpose

Description

public CairoPdfSurface::__construct ( string $file , float $width , float $height )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoPdfSurface::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPdfSurface::setSize

(PECL cairo >= 0.1.0)

CairoPdfSurface::setSizeThe setSize purpose

Description

public CairoPdfSurface::setSize ( float $width , float $height ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoPdfSurface::setSize() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoPsSurface class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoPsSurface extends CairoSurface {
/* Methods */
public __construct ( string $file , float $width , float $height )
public dscBeginPageSetup ( void ) : void
public dscBeginSetup ( void ) : void
public dscComment ( string $comment ) : void
public getEps ( void ) : bool
public static getLevels ( void ) : array
public static levelToString ( int $level ) : string
public restrictToLevel ( int $level ) : void
public setEps ( bool $level ) : void
public setSize ( float $width , float $height ) : void
/* Inherited methods */
public CairoSurface::__construct ( void )
public CairoSurface::copyPage ( void ) : void
public CairoSurface::createSimilar ( CairoSurface $other , int $content , string $width , string $height ) : void
public CairoSurface::finish ( void ) : void
public CairoSurface::flush ( void ) : void
public CairoSurface::getContent ( void ) : int
public CairoSurface::getDeviceOffset ( void ) : array
public CairoSurface::getFontOptions ( void ) : void
public CairoSurface::getType ( void ) : int
public CairoSurface::markDirty ( void ) : void
public CairoSurface::markDirtyRectangle ( float $x , float $y , float $width , float $height ) : void
public CairoSurface::setDeviceOffset ( float $x , float $y ) : void
public CairoSurface::setFallbackResolution ( float $x , float $y ) : void
public CairoSurface::showPage ( void ) : void
public CairoSurface::status ( void ) : int
public CairoSurface::writeToPng ( string $file ) : void
}

CairoPsSurface::__construct

(PECL cairo >= 0.1.0)

CairoPsSurface::__constructThe __construct purpose

Description

public CairoPsSurface::__construct ( string $file , float $width , float $height )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

file

Description...

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::dscBeginPageSetup

(PECL cairo >= 0.1.0)

CairoPsSurface::dscBeginPageSetupThe dscBeginPageSetup purpose

Description

public CairoPsSurface::dscBeginPageSetup ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPsSurface::dscBeginPageSetup() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::dscBeginSetup

(PECL cairo >= 0.1.0)

CairoPsSurface::dscBeginSetupThe dscBeginSetup purpose

Description

public CairoPsSurface::dscBeginSetup ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPsSurface::dscBeginSetup() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::dscComment

(PECL cairo >= 0.1.0)

CairoPsSurface::dscCommentThe dscComment purpose

Description

public CairoPsSurface::dscComment ( string $comment ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

comment

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::dscComment() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::getEps

(PECL cairo >= 0.1.0)

CairoPsSurface::getEpsThe getEps purpose

Description

public CairoPsSurface::getEps ( void ) : bool

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPsSurface::getEps() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::getLevels

(PECL cairo >= 0.1.0)

CairoPsSurface::getLevelsThe getLevels purpose

Description

public static CairoPsSurface::getLevels ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPsSurface::getLevels() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::levelToString

(PECL cairo >= 0.1.0)

CairoPsSurface::levelToStringThe levelToString purpose

Description

public static CairoPsSurface::levelToString ( int $level ) : string

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

level

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::levelToString() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::restrictToLevel

(PECL cairo >= 0.1.0)

CairoPsSurface::restrictToLevelThe restrictToLevel purpose

Description

public CairoPsSurface::restrictToLevel ( int $level ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

level

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::restrictToLevel() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::setEps

(PECL cairo >= 0.1.0)

CairoPsSurface::setEpsThe setEps purpose

Description

public CairoPsSurface::setEps ( bool $level ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

level

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::setEps() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPsSurface::setSize

(PECL cairo >= 0.1.0)

CairoPsSurface::setSizeThe setSize purpose

Description

public CairoPsSurface::setSize ( float $width , float $height ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

width

Description...

height

Description...

Return Values

Description...

Examples

Example #1 CairoPsSurface::setSize() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoSurfaceType class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoSurfaceType {
/* Constants */
const integer IMAGE = 0 ;
const integer PDF = 1 ;
const integer PS = 2 ;
const integer XLIB = 3 ;
const integer XCB = 4 ;
const integer GLITZ = 5 ;
const integer QUARTZ = 6 ;
const integer WIN32 = 7 ;
const integer BEOS = 8 ;
const integer DIRECTFB = 9 ;
const integer SVG = 10 ;
const integer OS2 = 11 ;
const integer WIN32_PRINTING = 12 ;
const integer QUARTZ_IMAGE = 13 ;
}

Predefined Constants

CairoSurfaceType::IMAGE

Description here...

CairoSurfaceType::PDF

Description here...

CairoSurfaceType::PS

Description here...

CairoSurfaceType::XLIB

Description here...

CairoSurfaceType::XCB

Description here...

CairoSurfaceType::GLITZ

Description here...

CairoSurfaceType::QUARTZ

Description here...

CairoSurfaceType::WIN32

Description here...

CairoSurfaceType::BEOS

Description here...

CairoSurfaceType::DIRECTFB

Description here...

CairoSurfaceType::SVG

Description here...

CairoSurfaceType::OS2

Description here...

CairoSurfaceType::WIN32_PRINTING

Description here...

CairoSurfaceType::QUARTZ_IMAGE

Description here...



The CairoFontFace class

(PECL cairo >= 0.1.0)

Introduction

CairoFontFace abstract class represents a particular font at a particular weight, slant, and other characteristic but no transformation or size.

Note: This class can not be instantiated directly, it is created by CairoContext::getFontFace() or cairo_scaled_font_get_font_face().

Class synopsis

CairoFontFace {
/* Methods */
public __construct ( void )
public getType ( void ) : int
public status ( void ) : int
}

CairoFontFace::__construct

(PECL cairo >= 0.1.0)

CairoFontFace::__constructCreates a new CairoFontFace object

Description

public CairoFontFace::__construct ( void )

CairoFontFace class represents a particular font at a particular weight, slant, and other characteristic but no transformation or size.

Note: This class can't be instantiated directly it is created by CairoContext::getFontFace() or cairo_scaled_font_get_font_face()

Parameters

This function has no parameters.

Return Values

CairoFontFace

Examples

Example #1 CairoFontFace::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Class::Method()



CairoFontFace::getType

cairo_font_face_get_type

(PECL cairo >= 0.1.0)

CairoFontFace::getType -- cairo_font_face_get_typeRetrieves the font face type

Description

Object oriented style (method):

public CairoFontFace::getType ( void ) : int

Procedural style:

cairo_font_face_get_type ( CairoFontFace $fontface ) : int

This function returns the type of the backend used to create a font face. See CairoFontType class constants for available types.

Parameters

This function has no parameters.

Return Values

A font type that can be any one defined in CairoFontType

Examples

Example #1 CairoFontFace::getType() example

<?php

// Creates the font face
$fontface = new CairoToyFontFace('sans-serif');

// Get the font face type
var_dump($fontface->getType());

?>

The above example will output something similar to:

   int(0)
   

See Also

  • Classname::Method()



CairoFontFace::status

cairo_font_face_status

(PECL cairo >= 0.1.0)

CairoFontFace::status -- cairo_font_face_statusCheck for CairoFontFace errors

Description

Object oriented style (method):

public CairoFontFace::status ( void ) : int

Procedural style:

cairo_font_face_status ( CairoFontFace $fontface ) : int

Checks whether an error has previously occurred for this font face

Parameters

fontface

A valid CairoFontFace object

Return Values

CAIRO_STATUS_SUCCESS or another error such as CAIRO_STATUS_NO_MEMORY.

Examples

Example #1 Object oriented style

<?php

// Creates the font face
$fontface = new CairoToyFontFace('sans-serif');

// Get the font face status
var_dump($fontface->status()); // should be the value of CAIRO_STATUS_SUCCESS

?>

The above example will output something similar to:

   int(0)
   

Example #2 Procedural style

<?php

// Creates the font face
$fontface = new CairoToyFontFace('sans-serif');

// Get the font face status
var_dump(cairo_font_face_status($fontface)); // should be the value of CAIRO_STATUS_SUCCESS

?>

The above example will output something similar to:

   int(0)
   

See Also

  • Classname::Method()


Table of Contents



The CairoFontOptions class

(PECL cairo >= 0.1.0)

Introduction

An opaque structure holding all options that are used when rendering fonts.

Individual features of a cairo_font_options_t can be set or accessed using functions named cairo_font_options_set_feature_name and cairo_font_options_get_feature_name, like cairo_font_options_set_antialias() and cairo_font_options_get_antialias().

New features may be added to CairoFontOptions in the future. For this reason CairoFontOptions::copy(), CairoFontOptions::equal(), CairoFontOptions::merge(), CairoFontOptions::hash() (cairo_font_options_copy(), cairo_font_options_equal(), cairo_font_options_merge(), and cairo_font_options_hash() in procedural way) should be used to copy, check for equality, merge, or compute a hash value of CairoFontOptions objects.

Class synopsis

CairoFontOptions {
/* Methods */
public __construct ( void )
public equal ( CairoFontOptions $other ) : bool
public getAntialias ( void ) : int
public getHintMetrics ( void ) : int
public getHintStyle ( void ) : int
public getSubpixelOrder ( void ) : int
public hash ( void ) : int
public merge ( CairoFontOptions $other ) : void
public setAntialias ( int $antialias ) : void
public setHintMetrics ( int $hint_metrics ) : void
public setHintStyle ( int $hint_style ) : void
public setSubpixelOrder ( int $subpixel_order ) : void
public status ( void ) : int
}

CairoFontOptions::__construct

(PECL cairo >= 0.1.0)

CairoFontOptions::__constructThe __construct purpose

Description

public CairoFontOptions::__construct ( void )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoFontOptions::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::equal

(PECL cairo >= 0.1.0)

CairoFontOptions::equalThe equal purpose

Description

public CairoFontOptions::equal ( CairoFontOptions $other ) : bool

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

other

Description...

Return Values

Description...

Examples

Example #1 CairoFontOptions::equal() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::getAntialias

cairo_get_antialias

(PECL cairo >= 0.1.0)

CairoFontOptions::getAntialias -- cairo_get_antialiasThe getAntialias purpose

Description

Object oriented style (method):

public CairoFontOptions::getAntialias ( void ) : int

Procedural style:

cairo_get_antialias ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::getHintMetrics

(PECL cairo >= 0.1.0)

CairoFontOptions::getHintMetricsThe getHintMetrics purpose

Description

public CairoFontOptions::getHintMetrics ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoFontOptions::getHintMetrics() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::getHintStyle

(PECL cairo >= 0.1.0)

CairoFontOptions::getHintStyleThe getHintStyle purpose

Description

public CairoFontOptions::getHintStyle ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoFontOptions::getHintStyle() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::getSubpixelOrder

(PECL cairo >= 0.1.0)

CairoFontOptions::getSubpixelOrderThe getSubpixelOrder purpose

Description

public CairoFontOptions::getSubpixelOrder ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoFontOptions::getSubpixelOrder() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::hash

(PECL cairo >= 0.1.0)

CairoFontOptions::hashThe hash purpose

Description

public CairoFontOptions::hash ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoFontOptions::hash() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::merge

(PECL cairo >= 0.1.0)

CairoFontOptions::mergeThe merge purpose

Description

public CairoFontOptions::merge ( CairoFontOptions $other ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

other

Description...

Return Values

Description...

Examples

Example #1 CairoFontOptions::merge() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::setAntialias

cairo_set_antialias

(PECL cairo >= 0.1.0)

CairoFontOptions::setAntialias -- cairo_set_antialiasThe setAntialias purpose

Description

Object oriented style (method):

public CairoFontOptions::setAntialias ( int $antialias ) : void

Procedural style:

cairo_set_antialias ( CairoContext $context [, int $antialias ] ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

antialias

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::setHintMetrics

(PECL cairo >= 0.1.0)

CairoFontOptions::setHintMetricsThe setHintMetrics purpose

Description

public CairoFontOptions::setHintMetrics ( int $hint_metrics ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

hint_metrics

Description...

Return Values

Description...

Examples

Example #1 CairoFontOptions::setHintMetrics() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::setHintStyle

(PECL cairo >= 0.1.0)

CairoFontOptions::setHintStyleThe setHintStyle purpose

Description

public CairoFontOptions::setHintStyle ( int $hint_style ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

hint_style

Description...

Return Values

Description...

Examples

Example #1 CairoFontOptions::setHintStyle() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::setSubpixelOrder

(PECL cairo >= 0.1.0)

CairoFontOptions::setSubpixelOrderThe setSubpixelOrder purpose

Description

public CairoFontOptions::setSubpixelOrder ( int $subpixel_order ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

subpixel_order

Description...

Return Values

Description...

Examples

Example #1 CairoFontOptions::setSubpixelOrder() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoFontOptions::status

cairo_status

(PECL cairo >= 0.1.0)

CairoFontOptions::status -- cairo_statusThe status purpose

Description

Object oriented style (method):

public CairoFontOptions::status ( void ) : int

Procedural style:

cairo_status ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoFontSlant class

(No version information available, might only be in Git)

Introduction

Specifies variants of a font face based on their slant.

Class synopsis

CairoFontSlant {
/* Constants */
const integer NORMAL = 0 ;
const integer ITALIC = 1 ;
const integer OBLIQUE = 2 ;
}

Predefined Constants

CairoFontSlant::NORMAL

Upright font style

CairoFontSlant::ITALIC

Italic font style

CairoFontSlant::OBLIQUE

Oblique font style



The CairoFontType class

(No version information available, might only be in Git)

Introduction

CairoFontType class is an abstract final class that contains constants used to describe the type of a given CairoFontFace or CairoScaledFont. The font types are also known as "font backends" within cairo.

The type of a CairoFontFace is determined by the how it is created, an example would be the CairoToyFontFace::__construct(). The CairoFontFace type can be queried with CairoFontFace::getType() or cairo_font_face_get_type()

The various CairoFontFace functions can be used with a font face of any type.

The type of a CairoScaledFont is determined by the type of the CairoFontFace passed to CairoScaledFont::__construct() or cairo_scaled_font_create(). The scaled font type can be queried with CairoScaledFont::getType() or cairo_scaled_font_get_type().

Class synopsis

CairoFontType {
/* Constants */
const integer TOY = 0 ;
const integer FT = 1 ;
const integer WIN32 = 2 ;
const integer QUARTZ = 3 ;
}

Predefined Constants

CairoFontType::TOY

The font was created using CairoToyFont api

CairoFontType::FT

The font is of type CairoFreeType

CairoFontType::WIN32

The font is of type Win32

CairoFontType::QUARTZ

The font is of type Quartz

CairoFontType::USER

The font was create using cairo's user font api



The CairoFontWeight class

(No version information available, might only be in Git)

Introduction

Specifies variants of a font face based on their weight.

Class synopsis

CairoFontWeight {
/* Constants */
const integer NORMAL = 0 ;
const integer BOLD = 1 ;
}

Predefined Constants

CairoFontWeight::NORMAL

Normal font weight

CairoFontWeight::BOLD

Bold font weight



The CairoScaledFont class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoScaledFont {
/* Methods */
public __construct ( CairoFontFace $font_face , CairoMatrix $matrix , CairoMatrix $ctm , CairoFontOptions $options )
public extents ( void ) : array
public getCtm ( void ) : CairoMatrix
public getFontFace ( void ) : void
public getFontMatrix ( void ) : void
public getFontOptions ( void ) : void
public getScaleMatrix ( void ) : void
public getType ( void ) : int
public glyphExtents ( array $glyphs ) : array
public status ( void ) : int
public textExtents ( string $text ) : array
}

CairoScaledFont::__construct

(PECL cairo >= 0.1.0)

CairoScaledFont::__constructThe __construct purpose

Description

public CairoScaledFont::__construct ( CairoFontFace $font_face , CairoMatrix $matrix , CairoMatrix $ctm , CairoFontOptions $options )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

font_face

Description...

matrix

Description...

ctm

Description...

options

Description...

Return Values

Description...

Examples

Example #1 CairoScaledFont::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::extents

(PECL cairo >= 0.1.0)

CairoScaledFont::extentsThe extents purpose

Description

public CairoScaledFont::extents ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoScaledFont::extents() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getCtm

(PECL cairo >= 0.1.0)

CairoScaledFont::getCtmThe getCtm purpose

Description

public CairoScaledFont::getCtm ( void ) : CairoMatrix

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoScaledFont::getCtm() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getFontFace

cairo_get_font_face

(PECL cairo >= 0.1.0)

CairoScaledFont::getFontFace -- cairo_get_font_faceThe getFontFace purpose

Description

Object oriented style (method):

public CairoScaledFont::getFontFace ( void ) : void

Procedural style:

cairo_get_font_face ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getFontMatrix

cairo_get_font_matrix

(PECL cairo >= 0.1.0)

CairoScaledFont::getFontMatrix -- cairo_get_font_matrixThe getFontMatrix purpose

Description

Object oriented style (method):

public CairoScaledFont::getFontMatrix ( void ) : void

Procedural style:

cairo_get_font_matrix ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getFontOptions

cairo_get_font_options

(PECL cairo >= 0.1.0)

CairoScaledFont::getFontOptions -- cairo_get_font_optionsThe getFontOptions purpose

Description

Object oriented style (method):

public CairoScaledFont::getFontOptions ( void ) : void

Procedural style:

cairo_get_font_options ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getScaleMatrix

(PECL cairo >= 0.1.0)

CairoScaledFont::getScaleMatrixThe getScaleMatrix purpose

Description

public CairoScaledFont::getScaleMatrix ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoScaledFont::getScaleMatrix() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::getType

(PECL cairo >= 0.1.0)

CairoScaledFont::getTypeThe getType purpose

Description

public CairoScaledFont::getType ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoScaledFont::getType() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::glyphExtents

(PECL cairo >= 0.1.0)

CairoScaledFont::glyphExtentsThe glyphExtents purpose

Description

public CairoScaledFont::glyphExtents ( array $glyphs ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

glyphs

Description...

Return Values

Description...

Examples

Example #1 CairoScaledFont::glyphExtents() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::status

cairo_status

(PECL cairo >= 0.1.0)

CairoScaledFont::status -- cairo_statusThe status purpose

Description

Object oriented style (method):

public CairoScaledFont::status ( void ) : int

Procedural style:

cairo_status ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoScaledFont::textExtents

cairo_text_extents

(PECL cairo >= 0.1.0)

CairoScaledFont::textExtents -- cairo_text_extentsThe textExtents purpose

Description

Object oriented style (method):

public CairoScaledFont::textExtents ( string $text ) : array

Procedural style:

cairo_text_extents ( CairoContext $context ) : array

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

text

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoToyFontFace class

(PECL cairo >= 0.1.0)

Introduction

The CairoToyFontFace class can be used instead of CairoContext::selectFontFace() to create a toy font independently of a context.

Class synopsis

CairoToyFontFace extends CairoFontFace {
/* Inherited methods */
}


The CairoPatternType class

(No version information available, might only be in Git)

Introduction

CairoPatternType is used to describe the type of a given pattern.

The type of a pattern is determined by the function used to create it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba() functions create CairoPatternType::SOLID patterns. The remaining cairo_pattern_create_* functions map to pattern types in obvious ways.

Class synopsis

CairoPatternType {
/* Constants */
const integer SOLID = 0 ;
const integer SURFACE = 1 ;
const integer LINEAR = 2 ;
const integer RADIAL = 3 ;
}

Predefined Constants

CairoPatternType::SOLID

The pattern is a solid (uniform) color. It may be opaque or translucent.

CairoPatternType::SURFACE

The pattern is a based on a surface (an image).

CairoPatternType::LINEAR

The pattern is a linear gradient.

CairoPatternType::RADIAL

The pattern is a radial gradient.



The CairoPattern class

(PECL cairo >= 0.1.0)

Introduction

CairoPattern is the abstract base class from which all the other pattern classes derive. It cannot be instantiated directly

Class synopsis

CairoPattern {
/* Methods */
public __construct ( void )
public getMatrix ( void ) : void
public getType ( void ) : int
public setMatrix ( CairoMatrix $matrix ) : void
public status ( void ) : int
}

CairoPattern::__construct

(PECL cairo >= 0.1.0)

CairoPattern::__constructThe __construct purpose

Description

public CairoPattern::__construct ( void )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPattern::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPattern::getMatrix

cairo_get_matrix

(PECL cairo >= 0.1.0)

CairoPattern::getMatrix -- cairo_get_matrixThe getMatrix purpose

Description

Object oriented style (method):

public CairoPattern::getMatrix ( void ) : void

Procedural style:

cairo_get_matrix ( CairoContext $context ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPattern::getType

(PECL cairo >= 0.1.0)

CairoPattern::getTypeThe getType purpose

Description

public CairoPattern::getType ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoPattern::getType() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPattern::setMatrix

cairo_set_matrix

(PECL cairo >= 0.1.0)

CairoPattern::setMatrix -- cairo_set_matrixThe setMatrix purpose

Description

Object oriented style (method):

public CairoPattern::setMatrix ( CairoMatrix $matrix ) : void

Procedural style:

cairo_set_matrix ( CairoContext $context , CairoMatrix $matrix ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

matrix

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoPattern::status

cairo_status

(PECL cairo >= 0.1.0)

CairoPattern::status -- cairo_statusThe status purpose

Description

Object oriented style (method):

public CairoPattern::status ( void ) : int

Procedural style:

cairo_status ( CairoContext $context ) : int

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoGradientPattern class

(PECL cairo >= 0.1.0)

Introduction

CairoGradientPattern is an abstract base class from which other Pattern classes derive. It cannot be instantiated directly.

Class synopsis

CairoGradientPattern extends CairoPattern {
/* Methods */
public addColorStopRgb ( float $offset , float $red , float $green , float $blue ) : void
public addColorStopRgba ( float $offset , float $red , float $green , float $blue , float $alpha ) : void
public getColorStopCount ( void ) : int
public getColorStopRgba ( int $index ) : array
public getExtend ( void ) : int
public setExtend ( int $extend ) : void
/* Inherited methods */
public CairoPattern::__construct ( void )
public CairoPattern::getMatrix ( void ) : void
public CairoPattern::getType ( void ) : int
public CairoPattern::setMatrix ( CairoMatrix $matrix ) : void
public CairoPattern::status ( void ) : int
}

CairoGradientPattern::addColorStopRgb

(PECL cairo >= 0.1.0)

CairoGradientPattern::addColorStopRgbThe addColorStopRgb purpose

Description

public CairoGradientPattern::addColorStopRgb ( float $offset , float $red , float $green , float $blue ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Description...

red

Description...

green

Description...

blue

Description...

Return Values

Description...

Examples

Example #1 CairoGradientPattern::addColorStopRgb() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoGradientPattern::addColorStopRgba

(PECL cairo >= 0.1.0)

CairoGradientPattern::addColorStopRgbaThe addColorStopRgba purpose

Description

public CairoGradientPattern::addColorStopRgba ( float $offset , float $red , float $green , float $blue , float $alpha ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

offset

Description...

red

Description...

green

Description...

blue

Description...

alpha

Description...

Return Values

Description...

Examples

Example #1 CairoGradientPattern::addColorStopRgba() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoGradientPattern::getColorStopCount

(PECL cairo >= 0.1.0)

CairoGradientPattern::getColorStopCountThe getColorStopCount purpose

Description

public CairoGradientPattern::getColorStopCount ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoGradientPattern::getColorStopCount() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoGradientPattern::getColorStopRgba

(PECL cairo >= 0.1.0)

CairoGradientPattern::getColorStopRgbaThe getColorStopRgba purpose

Description

public CairoGradientPattern::getColorStopRgba ( int $index ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

index

Description...

Return Values

Description...

Examples

Example #1 CairoGradientPattern::getColorStopRgba() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoGradientPattern::getExtend

(PECL cairo >= 0.1.0)

CairoGradientPattern::getExtendThe getExtend purpose

Description

public CairoGradientPattern::getExtend ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoGradientPattern::getExtend() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoGradientPattern::setExtend

(PECL cairo >= 0.1.0)

CairoGradientPattern::setExtendThe setExtend purpose

Description

public CairoGradientPattern::setExtend ( int $extend ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

extend

Description...

Return Values

Description...

Examples

Example #1 CairoGradientPattern::setExtend() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoSolidPattern class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoSolidPattern extends CairoPattern {
/* Methods */
public __construct ( float $red , float $green , float $blue [, float $alpha = 0 ] )
public getRgba ( void ) : array
/* Inherited methods */
public CairoPattern::__construct ( void )
public CairoPattern::getMatrix ( void ) : void
public CairoPattern::getType ( void ) : int
public CairoPattern::setMatrix ( CairoMatrix $matrix ) : void
public CairoPattern::status ( void ) : int
}

CairoSolidPattern::__construct

(PECL cairo >= 0.1.0)

CairoSolidPattern::__constructThe __construct purpose

Description

public CairoSolidPattern::__construct ( float $red , float $green , float $blue [, float $alpha = 0 ] )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

red

Description...

green

Description...

blue

Description...

alpha

Description...

Return Values

Description...

Examples

Example #1 CairoSolidPattern::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSolidPattern::getRgba

(PECL cairo >= 0.1.0)

CairoSolidPattern::getRgbaThe getRgba purpose

Description

public CairoSolidPattern::getRgba ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSolidPattern::getRgba() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoSurfacePattern class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoSurfacePattern extends CairoPattern {
/* Methods */
public __construct ( CairoSurface $surface )
public getExtend ( void ) : int
public getFilter ( void ) : int
public getSurface ( void ) : void
public setExtend ( int $extend ) : void
public setFilter ( int $filter ) : void
/* Inherited methods */
public CairoPattern::__construct ( void )
public CairoPattern::getMatrix ( void ) : void
public CairoPattern::getType ( void ) : int
public CairoPattern::setMatrix ( CairoMatrix $matrix ) : void
public CairoPattern::status ( void ) : int
}

CairoSurfacePattern::__construct

(PECL cairo >= 0.1.0)

CairoSurfacePattern::__constructThe __construct purpose

Description

public CairoSurfacePattern::__construct ( CairoSurface $surface )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

surface

Description...

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurfacePattern::getExtend

(PECL cairo >= 0.1.0)

CairoSurfacePattern::getExtendThe getExtend purpose

Description

public CairoSurfacePattern::getExtend ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::getExtend() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurfacePattern::getFilter

(PECL cairo >= 0.1.0)

CairoSurfacePattern::getFilterThe getFilter purpose

Description

public CairoSurfacePattern::getFilter ( void ) : int

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::getFilter() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurfacePattern::getSurface

(PECL cairo >= 0.1.0)

CairoSurfacePattern::getSurfaceThe getSurface purpose

Description

public CairoSurfacePattern::getSurface ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::getSurface() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurfacePattern::setExtend

(PECL cairo >= 0.1.0)

CairoSurfacePattern::setExtendThe setExtend purpose

Description

public CairoSurfacePattern::setExtend ( int $extend ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

extend

Description...

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::setExtend() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoSurfacePattern::setFilter

(PECL cairo >= 0.1.0)

CairoSurfacePattern::setFilterThe setFilter purpose

Description

public CairoSurfacePattern::setFilter ( int $filter ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

filter

Description...

Return Values

Description...

Examples

Example #1 CairoSurfacePattern::setFilter() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoLinearGradient class

(PECL cairo >= 0.1.0)

Introduction

Create a new CairoLinearGradient along the line defined

Class synopsis

CairoLinearGradient extends CairoGradientPattern {
/* Methods */
public __construct ( float $x0 , float $y0 , float $x1 , float $y1 )
public getPoints ( void ) : array
/* Inherited methods */
public CairoGradientPattern::addColorStopRgb ( float $offset , float $red , float $green , float $blue ) : void
public CairoGradientPattern::addColorStopRgba ( float $offset , float $red , float $green , float $blue , float $alpha ) : void
public CairoGradientPattern::getColorStopRgba ( int $index ) : array
public CairoGradientPattern::getExtend ( void ) : int
public CairoGradientPattern::setExtend ( int $extend ) : void
}

CairoLinearGradient::__construct

(PECL cairo >= 0.1.0)

CairoLinearGradient::__constructThe __construct purpose

Description

public CairoLinearGradient::__construct ( float $x0 , float $y0 , float $x1 , float $y1 )

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

x0

Description...

y0

Description...

x1

Description...

y1

Description...

Return Values

Description...

Examples

Example #1 CairoLinearGradient::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoLinearGradient::getPoints

(PECL cairo >= 0.1.0)

CairoLinearGradient::getPointsThe getPoints purpose

Description

public CairoLinearGradient::getPoints ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoLinearGradient::getPoints() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoRadialGradient class

(PECL cairo >= 0.1.0)

Introduction

Class synopsis

CairoRadialGradient extends CairoGradientPattern {
/* Methods */
public __construct ( float $x0 , float $y0 , float $r0 , float $x1 , float $y1 , float $r1 )
public getCircles ( void ) : array
/* Inherited methods */
public CairoGradientPattern::addColorStopRgb ( float $offset , float $red , float $green , float $blue ) : void
public CairoGradientPattern::addColorStopRgba ( float $offset , float $red , float $green , float $blue , float $alpha ) : void
public CairoGradientPattern::getColorStopRgba ( int $index ) : array
public CairoGradientPattern::getExtend ( void ) : int
public CairoGradientPattern::setExtend ( int $extend ) : void
}

CairoRadialGradient::__construct

(PECL cairo >= 0.1.0)

CairoRadialGradient::__constructThe __construct purpose

Description

Object oriented style:

public CairoRadialGradient::__construct ( float $x0 , float $y0 , float $r0 , float $x1 , float $y1 , float $r1 )

Procedural style:

Creates a new radial gradient CairoPattern between the two circles defined by (x0, y0, r0) and (x1, y1, r1). Before using the gradient pattern, a number of color stops should be defined using CairoRadialGradient::addColorStopRgb() or CairoRadialGradient::addColorStopRgba().

Note: The coordinates here are in pattern space. For a new pattern, pattern space is identical to user space, but the relationship between the spaces can be changed with CairoRadialGradient::setMatrix().

Parameters

x0

x coordinate for the center of the start circle.

y0

y coordinate for the center of the start circle.

r0

radius of the start circle.

x1

x coordinate for the center of the end circle.

y1

y coordinate for the center of the end circle.

r1

radius of the end circle.

Return Values

Description...

Examples

Example #1 CairoRadialGradient::__construct() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoRadialGradient::getCircles

(PECL cairo >= 0.1.0)

CairoRadialGradient::getCirclesThe getCircles purpose

Description

public CairoRadialGradient::getCircles ( void ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoRadialGradient::getCircles() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoAntialias class

(No version information available, might only be in Git)

Introduction

Enum class that specifies the type of antialiasing to do when rendering text or shapes.

Class synopsis

CairoAntialias {
/* Constants */
const integer MODE_DEFAULT = 0 ;
const integer MODE_NONE = 1 ;
const integer MODE_GRAY = 2 ;
const integer MODE_SUBPIXEL = 3 ;
}

Predefined Constants

CairoAntialias::MODE_DEFAULT

Use the default antialiasing for the subsystem and target device

CairoAntialias::MODE_NONE

Use a bilevel alpha mask

CairoAntialias::MODE_GRAY

Perform single-color antialiasing (using shades of gray for black text on a white background, for example).

CairoAntialias::MODE_SUBPIXEL

Perform antialiasing by taking advantage of the order of subpixel elements on devices such as LCD panels.



The CairoContent class

(No version information available, might only be in Git)

Introduction

CairoContent is used to describe the content that a surface will contain, whether color information, alpha information (translucence vs. opacity), or both.

Note: The large values here are designed to keep CairoContent values distinct from CairoContent values so that the implementation can detect the error if users confuse the two types.

Class synopsis

CairoContent {
/* Constants */
const integer COLOR = 4096 ;
const integer ALPHA = 8192 ;
const integer COLOR_ALPHA = 12288 ;
}

Predefined Constants

CairoContent::COLOR

The surface will hold color content only.

CairoContent::ALPHA

The surface will hold alpha content only.

CairoContent::COLOR_ALPHA

The surface will hold color and alpha content.



The CairoExtend class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoExtend {
/* Constants */
const integer NONE = 0 ;
const integer REPEAT = 1 ;
const integer REFLECT = 2 ;
const integer PAD = 3 ;
}

Predefined Constants

CairoExtend::NONE

Description here...

CairoExtend::REPEAT

Description here...

CairoExtend::REFLECT

Description here...

CairoExtend::PAD

Description here...



The CairoFormat class

(PECL cairo >= 0.1.0)

Introduction

CairoFormat enums are used to identify the memory format of the image data.

Class synopsis

CairoFormat {
/* Constants */
const integer ARGB32 = 0 ;
const integer RGB24 = 1 ;
const integer A8 = 2 ;
const integer A1 = 3 ;
/* Methods */
public static strideForWidth ( int $format , int $width ) : int
}

Predefined Constants

CairoFormat::ARGB32

Each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then red, then green, then blue. The 32-bit quantities are stored native-endian. Pre-multiplied alpha is used. (That is, 50% transparent red is 0x80800000, not 0x80ff0000.)

CairoFormat::RGB24

Each pixel is a 32-bit quantity, with the upper 8 bits unused. Red, Green, and Blue are stored in the remaining 24 bits in that order.

CairoFormat::A8

Each pixel is a 8-bit quantity holding an alpha value.

CairoFormat::A1

Each pixel is a 1-bit quantity holding an alpha value. Pixels are packed together into 32-bit quantities. The ordering of the bits matches the endianness of the platform. On a big-endian machine, the first pixel is in the uppermost bit, on a little-endian machine the first pixel is in the least-significant bit.


CairoFormat::strideForWidth

(PECL cairo >= 0.1.0)

CairoFormat::strideForWidthProvides an appropriate stride to use

Description

public static CairoFormat::strideForWidth ( int $format , int $width ) : int

This method provides a stride value that will respect all alignment requirements of the accelerated image-rendering code within cairo.

Parameters

format

The desired CairoFormat to use

width

The width of the image

Return Values

The appropriate stride to use given the desired format and width, or -1 if either the format is invalid or the width too large.

Examples

Example #1 CairoFormat::strideForWidth() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoFillRule class

(No version information available, might only be in Git)

Introduction

A CairoFillRule is used to select how paths are filled. For both fill rules, whether or not a point is included in the fill is determined by taking a ray from that point to infinity and looking at intersections with the path. The ray can be in any direction, as long as it doesn't pass through the end point of a segment or have a tricky intersection such as intersecting tangent to the path. (Note that filling is not actually implemented in this way. This is just a description of the rule that is applied.)

The default fill rule is CairoFillRule::WINDING.

Class synopsis

CairoFillRule {
/* Constants */
const integer WINDING = 0 ;
const integer EVEN_ODD = 1 ;
}

Predefined Constants

CairoFillRule::WINDING

If the path crosses the ray from left-to-right, counts +1. If the path crosses the ray from right to left, counts -1. (Left and right are determined from the perspective of looking along the ray from the starting point.) If the total count is non-zero, the point will be filled.

CairoFillRule::EVEN_ODD

Counts the total number of intersections, without regard to the orientation of the contour. If the total number of intersections is odd, the point will be filled.



The CairoFilter class

(No version information available, might only be in Git)

Introduction

A CairoFilter is used to indicate what filtering should be applied when reading pixel values from patterns. See CairoPattern::setSource() or cairo_pattern_set_source() for indicating the desired filter to be used with a particular pattern.

Class synopsis

CairoFilter {
/* Constants */
const integer FAST = 0 ;
const integer GOOD = 1 ;
const integer BEST = 2 ;
const integer NEAREST = 3 ;
const integer BILINEAR = 4 ;
const integer GAUSSIAN = 5 ;
}

Predefined Constants

CairoFilter::FAST

A high-performance filter, with quality similar to CairoFilter::NEAREST

CairoFilter::GOOD

A reasonable-performance filter, with quality similar to CairoFilter::BILINEAR

CairoFilter::BEST

The highest-quality available, performance may not be suitable for interactive use.

CairoFilter::NEAREST

Nearest-neighbor filtering

CairoFilter::BILINEAR

Linear interpolation in two dimensions

CairoFilter::GAUSSIAN

This filter value is currently unimplemented, and should not be used in current code.



The CairoHintMetrics class

(No version information available, might only be in Git)

Introduction

Specifies whether to hint font metrics; hinting font metrics means quantizing them so that they are integer values in device space. Doing this improves the consistency of letter and line spacing, however it also means that text will be laid out differently at different zoom factors.

Class synopsis

CairoHintMetrics {
/* Constants */
const integer METRICS_DEFAULT = 0 ;
const integer METRICS_OFF = 1 ;
const integer METRICS_ON = 2 ;
}

Predefined Constants

CairoHintMetrics::METRICS_DEFAULT

Hint metrics in the default manner for the font backend and target device

CairoHintMetrics::METRICS_OFF

Do not hint font metrics

CairoHintMetrics::METRICS_ON

Hint font metrics



The CairoHintStyle class

(No version information available, might only be in Git)

Introduction

Specifies the type of hinting to do on font outlines. Hinting is the process of fitting outlines to the pixel grid in order to improve the appearance of the result. Since hinting outlines involves distorting them, it also reduces the faithfulness to the original outline shapes. Not all of the outline hinting styles are supported by all font backends.

Class synopsis

CairoHintStyle {
/* Constants */
const integer STYLE_DEFAULT = 0 ;
const integer STYLE_NONE = 1 ;
const integer STYLE_SLIGHT = 2 ;
const integer STYLE_MEDIUM = 3 ;
const integer STYLE_FULL = 4 ;
}

Predefined Constants

CairoHintStyle::STYLE_DEFAULT

Use the default hint style for font backend and target device

CairoHintStyle::STYLE_NONE

Do not hint outlines

CairoHintStyle::STYLE_SLIGHT

Hint outlines slightly to improve contrast while retaining good fidelity to the original shapes.

CairoHintStyle::STYLE_MEDIUM

Hint outlines with medium strength giving a compromise between fidelity to the original shapes and contrast

CairoHintStyle::STYLE_FULL

Hint outlines to maximize contrast



The CairoLineCap class

(No version information available, might only be in Git)

Introduction

Specifies how to render the endpoints of the path when stroking.

The default line cap style is CairoLineCap::BUTT.

Class synopsis

CairoLineCap {
/* Constants */
const integer BUTT = 0 ;
const integer ROUND = 1 ;
const integer SQUARE = 2 ;
}

Predefined Constants

CairoLineCap::BUTT

Start(stop) the line exactly at the start(end) point

CairoLineCap::ROUND

Use a round ending, the center of the circle is the end point

CairoLineCap::SQUARE

Use squared ending, the center of the square is the end point



The CairoLineJoin class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoLineJoin {
/* Constants */
const integer MITER = 0 ;
const integer ROUND = 1 ;
const integer BEVEL = 2 ;
}

Predefined Constants

CairoLineJoin::MITER

Description here...

CairoLineJoin::ROUND

Description here...

CairoLineJoin::BEVEL

Description here...



The CairoMatrix class

(PECL cairo >= 0.1.0)

Introduction

Matrices are used throughout cairo to convert between different coordinate spaces.

Class synopsis

CairoMatrix {
/* Methods */
public __construct ([ float $xx = 1.0 [, float $yx = 0.0 [, float $xy = 0.0 [, float $yy = 1.0 [, float $x0 = 0.0 [, float $y0 = 0.0 ]]]]]] )
public static initIdentity ( void ) : void
public static initRotate ( float $radians ) : void
public static initScale ( float $sx , float $sy ) : void
public static initTranslate ( float $tx , float $ty ) : void
public invert ( void ) : void
public static multiply ( CairoMatrix $matrix1 , CairoMatrix $matrix2 ) : CairoMatrix
public rotate ( float $radians ) : void
public scale ( float $sx , float $sy ) : void
public transformDistance ( float $dx , float $dy ) : array
public transformPoint ( float $dx , float $dy ) : array
public translate ( float $tx , float $ty ) : void
}

CairoMatrix::__construct

cairo_matrix_init

(PECL cairo >= 0.1.0)

CairoMatrix::__construct -- cairo_matrix_initCreates a new CairoMatrix object

Description

Object oriented style (method):

public CairoMatrix::__construct ([ float $xx = 1.0 [, float $yx = 0.0 [, float $xy = 0.0 [, float $yy = 1.0 [, float $x0 = 0.0 [, float $y0 = 0.0 ]]]]]] )

Procedural style:

cairo_matrix_init ([ float $xx = 1.0 [, float $yx = 0.0 [, float $xy = 0.0 [, float $yy = 1.0 [, float $x0 = 0.0 [, float $y0 = 0.0 ]]]]]] ) : object

Returns new CairoMatrix object. Matrices are used throughout cairo to convert between different coordinate spaces. Sets matrix to be the affine transformation given by xx, yx, xy, yy, x0, y0. The transformation is given by: x_new = xx * x + xy * y + x0; and y_new = yx * x + yy * y + y0;

Parameters

xx

xx component of the affine transformation

yx

yx component of the affine transformation

xy

xy component of the affine transformation

yy

yy component of the affine transformation

x0

X translation component of the affine transformation

y0

Y translation component of the affine transformation

Return Values

Returns a new CairoMatrix object that can be used with surfaces, contexts, and patterns.

Examples

Example #1 Object oriented style

<?php
/* Create a new Matrix */
$matrix = new CairoMatrix(1.00.50.01.00.00.0);
?>

Example #2 Procedural style

<?php
/* Create a new Matrix */
$matrix cairo_matrix_init(1.00.50.01.00.00.0);
?>

See Also



CairoMatrix::initIdentity

cairo_matrix_init_identity

(PECL cairo >= 0.1.0)

CairoMatrix::initIdentity -- cairo_matrix_init_identityCreates a new identity matrix

Description

Object oriented style (method):

public static CairoMatrix::initIdentity ( void ) : void

Procedural style:

cairo_matrix_init_identity ( void ) : object

Creates a new matrix that is an identity transformation. An identity transformation means the source data is copied into the destination data without change

Parameters

This function has no parameters.

Return Values

Returns a new CairoMatrix object that can be used with surfaces, contexts, and patterns.

Examples

Example #1 Object oriented style

<?php
/* Create a new Matrix */
$matrix CairoMatrix::initIdentity();
?>

Example #2 Procedural style

<?php
/* Create a new Matrix */
$matrix cairo_matrix_init_identity();
?>

See Also



CairoMatrix::initRotate

cairo_matrix_init_rotate

(PECL cairo >= 0.1.0)

CairoMatrix::initRotate -- cairo_matrix_init_rotateCreates a new rotated matrix

Description

Object oriented style (method):

public static CairoMatrix::initRotate ( float $radians ) : void

Procedural style:

cairo_matrix_init_rotate ( float $radians ) : object

Creates a new matrix to a transformation that rotates by radians provided

Parameters

radians

angle of rotation, in radians. The direction of rotation is defined such that positive angles rotate in the direction from the positive X axis toward the positive Y axis. With the default axis orientation of cairo, positive angles rotate in a clockwise direction.

Return Values

Returns a new CairoMatrix object that can be used with surfaces, contexts, and patterns.

Examples

Example #1 Object oriented style

<?php
/* Create a new Matrix */
$matrix CairoMatrix::initRotate(0.3);
?>

Example #2 Procedural style

<?php
/* Create a new Matrix */
$matrix cairo_matrix_init_rotate(0.3);
?>

See Also



CairoMatrix::initScale

cairo_matrix_init_scale

(PECL cairo >= 0.1.0)

CairoMatrix::initScale -- cairo_matrix_init_scaleCreates a new scaling matrix

Description

Object oriented style (method):

public static CairoMatrix::initScale ( float $sx , float $sy ) : void

Procedural style:

cairo_matrix_init_scale ( float $sx , float $sy ) : object

Creates a new matrix to a transformation that scales by sx and sy in the X and Y dimensions, respectively.

Parameters

sx

scale factor in the X direction

sy

scale factor in the Y direction

Return Values

Returns a new CairoMatrix object that can be used with surfaces, contexts, and patterns.

Examples

Example #1 Object oriented style

<?php
/* Create a new Matrix */
$matrix CairoMatrix::initScale(1.02.0);
?>

Example #2 Procedural style

<?php
/* Create a new Matrix */
$matrix cairo_matrix_init_scale(1.02.0);
?>

See Also



CairoMatrix::initTranslate

cairo_matrix_init_translate

(PECL cairo >= 0.1.0)

CairoMatrix::initTranslate -- cairo_matrix_init_translateCreates a new translation matrix

Description

Object oriented style (method):

public static CairoMatrix::initTranslate ( float $tx , float $ty ) : void

Procedural style:

cairo_matrix_init_translate ( float $tx , float $ty ) : object

Creates a new matrix to a transformation that translates by tx and ty in the X and Y dimensions, respectively.

Parameters

tx

amount to translate in the X direction

ty

amount to translate in the Y direction

Return Values

Returns a new CairoMatrix object that can be used with surfaces, contexts, and patterns.

Examples

Example #1 Object oriented style

<?php
/* Create a new Matrix */
$matrix CairoMatrix::initTranslate(1.02.0);
?>

Example #2 Procedural style

<?php
/* Create a new Matrix */
$matrix cairo_matrix_init_translate(1.02.0);
?>

See Also



CairoMatrix::invert

(PECL cairo >= 0.1.0)

CairoMatrix::invertThe invert purpose

Description

public CairoMatrix::invert ( void ) : void

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

This function has no parameters.

Return Values

Description...

Examples

Example #1 CairoMatrix::invert() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoMatrix::multiply

(PECL cairo >= 0.1.0)

CairoMatrix::multiplyThe multiply purpose

Description

public static CairoMatrix::multiply ( CairoMatrix $matrix1 , CairoMatrix $matrix2 ) : CairoMatrix

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

matrix1

Description...

matrix2

Description...

Return Values

Description...

Examples

Example #1 CairoMatrix::multiply() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoMatrix::rotate

cairo_matrix_rotate

(PECL cairo >= 0.1.0)

CairoMatrix::rotate -- cairo_matrix_rotateThe rotate purpose

Description

Object oriented style (method):

public CairoMatrix::rotate ( float $radians ) : void

Procedural style:

cairo_matrix_rotate ( CairoContext $context , string $radians ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

radians

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoMatrix::scale

cairo_matrix_scale

(PECL cairo >= 0.1.0)

CairoMatrix::scale -- cairo_matrix_scaleApplies scaling to a matrix

Description

Object oriented style (method):

public CairoMatrix::scale ( float $sx , float $sy ) : void

Procedural style:

cairo_matrix_scale ( CairoContext $context , float $sx , float $sy ) : void

Applies scaling by sx, sy to the transformation in the matrix. The effect of the new transformation is to first scale the coordinates by sx and sy, then apply the original transformation to the coordinates.

Parameters

matrix

Procedural only - CairoMatrix instance

sx

scale factor in the X direction

sy

scale factor in the Y direction

Examples

Example #1 Object oriented style

<?php
/* Apply scaling to a matrix */
$matrix = new CairoMatrix(1.00.50.01.00.00.0);
$matrix->scale(0.22.0);
?>

Example #2 Procedural style

<?php
/* Apply scaling to a matrix */
$matrix cairo_matrix_init(1.00.50.01.00.00.0);
cairo_matrix_scale($matrix0.22.0);
?>

See Also



CairoMatrix::transformDistance

(PECL cairo >= 0.1.0)

CairoMatrix::transformDistanceThe transformDistance purpose

Description

public CairoMatrix::transformDistance ( float $dx , float $dy ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

dx

Description...

dy

Description...

Return Values

Description...

Examples

Example #1 CairoMatrix::transformDistance() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoMatrix::transformPoint

(PECL cairo >= 0.1.0)

CairoMatrix::transformPointThe transformPoint purpose

Description

public CairoMatrix::transformPoint ( float $dx , float $dy ) : array

The method description goes here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

dx

Description...

dy

Description...

Return Values

Description...

Examples

Example #1 CairoMatrix::transformPoint() example

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()



CairoMatrix::translate

cairo_translate

(PECL cairo >= 0.1.0)

CairoMatrix::translate -- cairo_translateThe translate purpose

Description

Object oriented style (method):

public CairoMatrix::translate ( float $tx , float $ty ) : void

Procedural style:

cairo_translate ( CairoContext $context , float $x , float $y ) : void

Description here.

Warning

This function is currently not documented; only its argument list is available.

Parameters

context

Description...

x

Description...

y

Description...

tx

Description...

ty

Description...

Return Values

Description...

Examples

Example #1 Object oriented style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

Example #2 Procedural style

<?php
/* ... */
?>

The above example will output something similar to:

   ...
   

See Also

  • Classname::Method()


Table of Contents



The CairoOperator class

(No version information available, might only be in Git)

Introduction

This is used to set the compositing operator for all cairo drawing operations.

The default operator is CairoOperator::OVER

The operators marked as unbounded modify their destination even outside of the mask layer (that is, their effect is not bound by the mask layer). However, their effect can still be limited by way of clipping.

To keep things simple, the operator descriptions here document the behavior for when both source and destination are either fully transparent or fully opaque. The actual implementation works for translucent layers too. For a more detailed explanation of the effects of each operator, including the mathematical definitions, see http://cairographics.org/operators/.

Class synopsis

CairoOperator {
/* Constants */
const integer CLEAR = 0 ;
const integer SOURCE = 1 ;
const integer OVER = 2 ;
const integer IN = 3 ;
const integer OUT = 4 ;
const integer ATOP = 5 ;
const integer DEST = 6 ;
const integer DEST_OVER = 7 ;
const integer DEST_IN = 8 ;
const integer DEST_OUT = 9 ;
const integer DEST_ATOP = 10 ;
const integer XOR = 11 ;
const integer ADD = 12 ;
const integer SATURATE = 13 ;
}

Predefined Constants

CairoOperator::CLEAR

Clear destination layer (bounded)

CairoOperator::SOURCE

Replace destination layer (bounded)

CairoOperator::OVER

Draw source layer on top of destination layer (bounded)

CairoOperator::IN

Draw source where there was destination content (unbounded)

CairoOperator::OUT

Draw source where there was no destination content (unbounded)

CairoOperator::ATOP

Draw source on top of destination content and only there

CairoOperator::DEST

Ignore the source

CairoOperator::DEST_OVER

Draw destination on top of source

CairoOperator::DEST_IN

Leave destination only where there was source content (unbounded)

CairoOperator::DEST_OUT

Leave destination only where there was no source content

CairoOperator::DEST_ATOP

Leave destination on top of source content and only there (unbounded)

CairoOperator::XOR

Source and destination are shown where there is only one of them

CairoOperator::ADD

Source and destination layers are accumulated

CairoOperator::SATURATE

Like CairoOperator::OVER, but assuming source and dest are disjoint geometries



The CairoPath class

(No version information available, might only be in Git)

Introduction

Note: CairoPath class cannot be instantiated directly, doing so will result in Fatal Error if used or passed

Class synopsis

CairoPath {
}


The CairoPsLevel class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoPsLevel {
/* Constants */
const integer LEVEL_2 = 0 ;
const integer LEVEL_3 = 1 ;
}

Predefined Constants

CairoPsLevel::LEVEL_2

Description here...

CairoPsLevel::LEVEL_3

Description here...



The CairoSubpixelOrder class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoSubpixelOrder {
/* Constants */
const integer ORDER_DEFAULT = 0 ;
const integer ORDER_RGB = 1 ;
const integer ORDER_BGR = 2 ;
const integer ORDER_VRGB = 3 ;
const integer ORDER_VBGR = 4 ;
}

Predefined Constants

CairoSubpixelOrder::ORDER_DEFAULT

Description here...

CairoSubpixelOrder::ORDER_RGB

Description here...

CairoSubpixelOrder::ORDER_BGR

Description here...

CairoSubpixelOrder::ORDER_VRGB

Description here...

CairoSubpixelOrder::ORDER_VBGR

Description here...



The CairoSvgVersion class

(No version information available, might only be in Git)

Introduction

Class synopsis

CairoSvgVersion {
/* Constants */
const integer VERSION_1_1 = 0 ;
const integer VERSION_1_2 = 1 ;
}

Predefined Constants

CairoSvgVersion::VERSION_1_1

Description here...

CairoSvgVersion::VERSION_1_2

Description here...




Exchangeable image information


Introduction

With the exif extension you are able to work with image meta data. For example, you may use exif functions to read meta data of pictures taken from digital cameras by working with information stored in the headers. These are commonly found in JPEG and TIFF images.



Installing/Configuring

Table of Contents


Requirements

Your PHP must be compiled in with --enable-exif. To enable multibyte support in EXIF tags, the mbstring extension must be enabled by compiling PHP with --enable-mbstring. PHP does not require any additional library for the exif module.

Windows only: The mbstring extension must always be enabled. Note that mbstring extension must be loaded prior to EXIF in php.ini.



Installation

To enable exif-support configure PHP with --enable-exif

Windows users must enable both the php_mbstring.dll and php_exif.dll DLL's in php.ini. The php_mbstring.dll DLL must be loaded before the php_exif.dll DLL so adjust your php.ini accordingly.



Runtime Configuration

The behaviour of these functions is affected by settings in php.ini.

Exif supports automatically conversion for Unicode and JIS character encodings of user comments when module mbstring is available. This is done by first decoding the comment using the specified characterset. The result is then encoded with another characterset which should match your HTTP output.
Exif configuration options
Name Default Changeable Changelog
exif.encode_unicode "ISO-8859-15" PHP_INI_ALL  
exif.decode_unicode_motorola "UCS-2BE" PHP_INI_ALL  
exif.decode_unicode_intel "UCS-2LE" PHP_INI_ALL  
exif.encode_jis "" PHP_INI_ALL  
exif.decode_jis_motorola "JIS" PHP_INI_ALL  
exif.decode_jis_intel "JIS" PHP_INI_ALL  
For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set.

Here's a short explanation of the configuration directives.

exif.encode_unicode string

exif.encode_unicode defines the characterset UNICODE user comments are handled. This defaults to ISO-8859-15 which should work for most non Asian countries. The setting can be empty or must be an encoding supported by mbstring. If it is empty the current internal encoding of mbstring is used.

exif.decode_unicode_motorola string

exif.decode_unicode_motorola defines the image internal characterset for Unicode encoded user comments if image is in motorola byte order (big-endian). This setting cannot be empty but you can specify a list of encodings supported by mbstring. The default is UCS-2BE.

exif.decode_unicode_intel string

exif.decode_unicode_intel defines the image internal characterset for Unicode encoded user comments if image is in intel byte order (little-endian). This setting cannot be empty but you can specify a list of encodings supported by mbstring. The default is UCS-2LE.

exif.encode_jis string

exif.encode_jis defines the characterset JIS user comments are handled. This defaults to an empty value which forces the functions to use the current internal encoding of mbstring.

exif.decode_jis_motorola string

exif.decode_jis_motorola defines the image internal characterset for JIS encoded user comments if image is in motorola byte order (big-endian). This setting cannot be empty but you can specify a list of encodings supported by mbstring. The default is JIS.

exif.decode_jis_intel string

exif.decode_jis_intel defines the image internal characterset for JIS encoded user comments if image is in intel byte order (little-endian). This setting cannot be empty but you can specify a list of encodings supported by mbstring. The default is JIS.



Resource Types

This extension has no resource types defined.




Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

EXIF_USE_MBSTRING (integer)
This constant has a value of 1 if the mbstring is enabled, otherwise it has a value of 0.

The exif_imagetype() lists several related built-in constants.



Exif Functions


exif_imagetype

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

exif_imagetypeDetermine the type of an image

Description

exif_imagetype ( string $filename ) : int

exif_imagetype() reads the first bytes of an image and checks its signature.

exif_imagetype() can be used to avoid calls to other exif functions with unsupported file types or in conjunction with $_SERVER['HTTP_ACCEPT'] to check whether or not the viewer is able to see a specific image in the browser.

Parameters

filename
The image being checked.

Return Values

When a correct signature is found, the appropriate constant value will be returned otherwise the return value is FALSE. The return value is the same value that getimagesize() returns in index 2 but exif_imagetype() is much faster.

Note:

exif_imagetype() will emit an E_NOTICE and return FALSE if it is unable to read enough bytes from the file to determine the image type.

Changelog

Version Description
7.1.0 Added WebP support.
5.3.0 Added icon support.

Predefined Constants

The following constants are defined, and represent possible exif_imagetype() return values:
Imagetype Constants
Value Constant
1 IMAGETYPE_GIF
2 IMAGETYPE_JPEG
3 IMAGETYPE_PNG
4 IMAGETYPE_SWF
5 IMAGETYPE_PSD
6 IMAGETYPE_BMP
7 IMAGETYPE_TIFF_II (intel byte order)
8 IMAGETYPE_TIFF_MM (motorola byte order)
9 IMAGETYPE_JPC
10 IMAGETYPE_JP2
11 IMAGETYPE_JPX
12 IMAGETYPE_JB2
13 IMAGETYPE_SWC
14 IMAGETYPE_IFF
15 IMAGETYPE_WBMP
16 IMAGETYPE_XBM
17 IMAGETYPE_ICO
18 IMAGETYPE_WEBP

Examples

Example #1 exif_imagetype() example

<?php
if (exif_imagetype('image.gif') != IMAGETYPE_GIF) {
    echo 
'The picture is not a gif';
}
?>

See Also



exif_read_data

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

exif_read_dataReads the EXIF headers from an image file

Description

exif_read_data ( mixed $stream [, string $sections = NULL [, bool $arrays = FALSE [, bool $thumbnail = FALSE ]]] ) : array

exif_read_data() reads the EXIF headers from an image file. This way you can read meta data generated by digital cameras.

EXIF headers tend to be present in JPEG/TIFF images generated by digital cameras, but unfortunately each digital camera maker has a different idea of how to actually tag their images, so you can't always rely on a specific Exif header being present.

Height and Width are computed the same way getimagesize() does so their values must not be part of any header returned. Also, html is a height/width text string to be used inside normal HTML.

When an Exif header contains a Copyright note, this itself can contain two values. As the solution is inconsistent in the Exif 2.10 standard, the COMPUTED section will return both entries Copyright.Photographer and Copyright.Editor while the IFD0 sections contains the byte array with the NULL character that splits both entries. Or just the first entry if the datatype was wrong (normal behaviour of Exif). The COMPUTED will also contain the entry Copyright which is either the original copyright string, or a comma separated list of the photo and editor copyright.

The tag UserComment has the same problem as the Copyright tag. It can store two values. First the encoding used, and second the value itself. If so the IFD section only contains the encoding or a byte array. The COMPUTED section will store both in the entries UserCommentEncoding and UserComment. The entry UserComment is available in both cases so it should be used in preference to the value in IFD0 section.

exif_read_data() also validates EXIF data tags according to the EXIF specification (» http://exif.org/Exif2-2.PDF, page 20).

Note:

Windows Me/XP can both wipe the Exif headers when connecting to a camera.

Parameters

stream

The location of the image file. This can either be a path to the file (stream wrappers are also supported as usual) or a stream resource.

sections

Is a comma separated list of sections that need to be present in file to produce a result array. If none of the requested sections could be found the return value is FALSE.
FILE FileName, FileSize, FileDateTime, SectionsFound
COMPUTED html, Width, Height, IsColor, and more if available. Height and Width are computed the same way getimagesize() does so their values must not be part of any header returned. Also, html is a height/width text string to be used inside normal HTML.
ANY_TAG Any information that has a Tag e.g. IFD0, EXIF, ...
IFD0 All tagged data of IFD0. In normal imagefiles this contains image size and so forth.
THUMBNAIL A file is supposed to contain a thumbnail if it has a second IFD. All tagged information about the embedded thumbnail is stored in this section.
COMMENT Comment headers of JPEG images.
EXIF The EXIF section is a sub section of IFD0. It contains more detailed information about an image. Most of these entries are digital camera related.

arrays

Specifies whether or not each section becomes an array. The sections COMPUTED, THUMBNAIL, and COMMENT always become arrays as they may contain values whose names conflict with other sections.

thumbnail

When set to TRUE the thumbnail itself is read. Otherwise, only the tagged data is read.

Return Values

It returns an associative array where the array indexes are the header names and the array values are the values associated with those headers. If no data can be returned, exif_read_data() will return FALSE.

Changelog

Version Description
7.2.0 The filename parameter was renamed to stream and now supports both local files or stream resources.
7.2.0 Support for the following EXIF formats were added:
  • Samsung
  • DJI
  • Panasonic
  • Sony
  • Pentax
  • Minolta
  • Sigma/Foveon
  • AGFA
  • Kyocera
  • Ricoh
  • Epson

Examples

Example #1 exif_read_data() example

<?php
echo "test1.jpg:<br />\n";
$exif exif_read_data('tests/test1.jpg''IFD0');
echo 
$exif===false "No header data found.<br />\n" "Image contains headers<br />\n";

$exif exif_read_data('tests/test2.jpg'0true);
echo 
"test2.jpg:<br />\n";
foreach (
$exif as $key => $section) {
    foreach (
$section as $name => $val) {
        echo 
"$key.$name$val<br />\n";
    }
}
?>

The first call fails because the image has no header information.

The above example will output something similar to:

   test1.jpg:
   No header data found.
   test2.jpg:
   FILE.FileName: test2.jpg
   FILE.FileDateTime: 1017666176
   FILE.FileSize: 1240
   FILE.FileType: 2
   FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, COMMENT
   COMPUTED.html: width="1" height="1"
   COMPUTED.Height: 1
   COMPUTED.Width: 1
   COMPUTED.IsColor: 1
   COMPUTED.ByteOrderMotorola: 1
   COMPUTED.UserComment: Exif test image.
   COMPUTED.UserCommentEncoding: ASCII
   COMPUTED.Copyright: Photo (c) M.Boerger, Edited by M.Boerger.
   COMPUTED.Copyright.Photographer: Photo (c) M.Boerger
   COMPUTED.Copyright.Editor: Edited by M.Boerger.
   IFD0.Copyright: Photo (c) M.Boerger
   IFD0.UserComment: ASCII
   THUMBNAIL.JPEGInterchangeFormat: 134
   THUMBNAIL.JPEGInterchangeFormatLength: 523
   COMMENT.0: Comment #1.
   COMMENT.1: Comment #2.
   COMMENT.2: Comment #3end
   THUMBNAIL.JPEGInterchangeFormat: 134
   THUMBNAIL.Thumbnail.Height: 1
   THUMBNAIL.Thumbnail.Height: 1
   

Example #2 exif_read_data() with streams available as of PHP 7.2.0

<?php
// Open a the file, this should be in binary mode
$fp fopen('/path/to/image.jpg''rb');

if (!
$fp) {
    echo 
'Error: Unable to open image for reading';
    exit;
}

// Attempt to read the exif headers
$headers exif_read_data($fp);

if (!
$headers) {
    echo 
'Error: Unable to read exif headers';
    exit;
}

// Print the 'COMPUTED' headers
echo 'EXIF Headers:' PHP_EOL;

foreach (
$headers['COMPUTED'] as $header => $value) {
    
printf(' %s => %s%s'$header$valuePHP_EOL);
}
?>

The above example will output something similar to:

   EXIF Headers:
    Height => 576
    Width => 1024
    IsColor => 1
    ByteOrderMotorola => 0
    ApertureFNumber => f/5.6
    UserComment =>
    UserCommentEncoding => UNDEFINED
    Copyright => Denis
    Thumbnail.FileType => 2
    Thumbnail.MimeType => image/jpeg
   

Notes

Note:

If mbstring is enabled, exif will attempt to process the unicode and pick a charset as specified by exif.decode_unicode_motorola and exif.decode_unicode_intel. The exif extension will not attempt to figure out the encoding on its own, and it is up to the user to properly specify the encoding for which to use for decoding by setting one of these two ini directives prior to calling exif_read_data().

Note:

If the stream is used to pass a stream to this function, then the stream must be seekable. Note that the file pointer position is not changed after this function returns.

See Also



exif_tagname

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

exif_tagnameGet the header name for an index

Description

exif_tagname ( int $index ) : string

Parameters

index

The Tag ID for which a Tag Name will be looked up.

Return Values

Returns the header name, or FALSE if index is not a defined EXIF tag id.

Examples

Example #1 exif_tagname() example

<?php
echo "256: ".exif_tagname(256).PHP_EOL;
echo 
"257: ".exif_tagname(257).PHP_EOL;
?>

The above example will output:

   256: ImageWidth
   257: ImageLength
   

See Also



exif_thumbnail

(PHP 4 >= 4.2.0, PHP 5, PHP 7)

exif_thumbnailRetrieve the embedded thumbnail of an image

Description

exif_thumbnail ( mixed $stream [, int &$width [, int &$height [, int &$imagetype ]]] ) : string

exif_thumbnail() reads the embedded thumbnail of an image.

If you want to deliver thumbnails through this function, you should send the mimetype information using the header() function.

It is possible that exif_thumbnail() cannot create an image but can determine its size. In this case, the return value is FALSE but width and height are set.

Parameters

stream

The location of the image file. This can either be a path to the file or a stream resource.

width

The return width of the returned thumbnail.

height

The returned height of the returned thumbnail.

imagetype

The returned image type of the returned thumbnail. This is either TIFF or JPEG.

Return Values

Returns the embedded thumbnail, or FALSE if the image contains no thumbnail.

Examples

Example #1 exif_thumbnail() example

<?php
$image 
exif_thumbnail('/path/to/image.jpg'$width$height$type);

if (
$image!==false) {
    
header('Content-type: ' .image_type_to_mime_type($type));
    echo 
$image;
    exit;
} else {
    
// no thumbnail available, handle the error here
    
echo 'No thumbnail available';
}
?>

Changelog

Version Description
7.2.0 The filename parameter was renamed to stream and now supports both local files or stream resources.

Notes

Note:

If the stream is used to pass a stream to this function, then the stream must be seekable. Note that the file pointer position is not changed after this function returns.

See Also



read_exif_data

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

read_exif_dataAlias of exif_read_data()

Description

This function is an alias of: exif_read_data().

Changelog

Version Description
7.2.0 This function alias was deprecated.


Table of Contents




Image Processing and GD


Introduction

PHP is not limited to creating just HTML output. It can also be used to create and manipulate image files in a variety of different image formats, including GIF, PNG, JPEG, WBMP, and XPM. Even more conveniently, PHP can output image streams directly to a browser. You will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.

You can use the image functions in PHP to get the size of JPEG, GIF, PNG, SWF, TIFF and JPEG2000 images.

With the exif extension, you are able to work with information stored in headers of JPEG and TIFF images. This way you can read meta data generated by digital cameras. The exif functions do not require the GD library.

Note: Read the requirements section about how to expand image capabilities to read, write and modify images. To read meta data of pictures taken by digital cameras you need the above mentioned exif extension.

Note: The getimagesize() function does not require the GD extension.

Caution

While the bundled version of the GD library uses the Zend memory manager to allocate memory, system versions do not, so that memory_limit does not apply.

GD supports a varity of formats, below is a list of formats supported by GD and notes to their availability including read/write support.

Formats supported by GD
Format Read support Write support Notes
JPEG TRUE TRUE  
PNG TRUE TRUE  
GIF TRUE TRUE Available as of GD 2.0.28 and PHP 5.0.1
XBM TRUE TRUE  
XPM TRUE FALSE Read support available on Windows as of PHP 5.3.19.
WBMP TRUE TRUE  
WebP TRUE TRUE PHP 5.4+
BMP TRUE TRUE Available as of GD 2.1.0 and PHP 7.2.0

Despite most formats being available for both reading and writing in the above table, doesn't mean that PHP was compiled with support for them. To find out which formats that was available to GD during compilation, use the gd_info() function, for more information about compiling support for one or more formats, see the installation chapter.



Installing/Configuring

Table of Contents


Requirements

If you have the GD library (available at » http://www.libgd.org/) you will also be able to create and manipulate images.

The format of images you are able to manipulate depend on the version of GD you install, and any other libraries GD might need to access those image formats. GIF support is available as of gd-2.0.28.

Note: libgd-2.0.4 or higher is required. As of PHP 5.5 libgd-2.1.0 or higher is required. Alternatively, use the bundled GD library that ships with PHP.

You may wish to enhance GD to handle more image formats.
Supported image formats
Image format Library to download Notes
gif   Only supported in GD versions newer than gd-2.0.28. Write support is available as of PHP 5.0.1.
jpeg » http://www.ijg.org/ When building the jpeg library (prior to building PHP) you must use the --enable-shared option in the configure step. If you do not, you will receive an error saying libjpeg.(a|so) not found when you get to the configure step of building PHP.
png » http://www.libpng.org/pub/png/libpng.html
xpm » ftp://metalab.unc.edu/pub/Linux/libs/X/!INDEX.html It's likely you have this library already available, if your system has an installed X-Environment.

You may wish to enhance GD to deal with different fonts. The following font libraries are supported:
Supported font libraries
Font library Download Notes
FreeType 1.x » http://www.freetype.org/ Support for FreeType 1.x has been removed as of PHP 5.3.0.
FreeType 2 » http://www.freetype.org/  
T1lib » ftp://sunsite.unc.edu/pub/Linux/libs/graphics/) Support for Postscript Type 1 fonts (Removed as of PHP 7.0.0).



Installation

To enable GD-support configure PHP --with-gd[=DIR], where DIR is the GD base install directory. To use the recommended bundled version of the GD library, use the configure option --with-gd. GD library requires libpng and libjpeg to compile. As of PHP 7.4.0, --with-gd becomes --enable-gd (whether to enable the extension at all) and --with-external-gd (to opt into using an external libgd, rather than the bundled one).

In Windows, you'll include the GD2 DLL php_gd2.dll as an extension in php.ini.

Enhance the capabilities of GD to handle more image formats by specifying the --with-XXXX configure switch to your PHP configure line.
Supported image formats
Image Format Configure Switch
jpeg To enable support for jpeg add --with-jpeg-dir=DIR. Jpeg 6b, 7 or 8 are supported. As of PHP 7.4.0, use --with-jpeg instead.
png To enable support for png add --with-png-dir=DIR. Note, libpng requires the zlib library, therefore add --with-zlib-dir[=DIR] to your configure line. As of PHP 7.4.0, --with-png-dir and --with-zlib-dir have been removed. libpng and zlib are required.
xpm To enable support for xpm add --with-xpm-dir=DIR. If configure is not able to find the required libraries, you may add the path to your X11 libraries. As of PHP 7.4.0, use --with-xpm instead.
webp To enable support for webp add --with-vpx-dir=DIR. Available as of PHP 5.4.0. As of PHP 7.0.0 --with-webp-dir=DIR has to be added, i.e. support for libvpx has been removed in favor of libwebp. As of PHP 7.4.0, use --with-webp instead.

Note: When compiling PHP with libpng, you must use the same version that was linked with the GD library.

Enhance the capabilities of GD to deal with different fonts by specifying the --with-XXXX configure switch to your PHP configure line.
Supported font libraries
Font library Configure Switch
FreeType 2 To enable support for FreeType 2 add --with-freetype-dir=DIR. As of PHP 7.4.0 use --with-freetype instead, which relies on pkg-config.
T1lib To enable support for T1lib (Postscript Type 1 fonts) add --with-t1lib[=DIR] (Removed as of PHP 7.0.0).
Native TrueType string function To enable support for native TrueType string function add --enable-gd-native-ttf. (Effectless as of PHP 5.5.0; removed as of PHP 7.2.0.)



Runtime Configuration

The behaviour of these functions is affected by settings in php.ini.

Image Configure Options
Name Default Changeable Changelog
gd.jpeg_ignore_warning "1" PHP_INI_ALL Available since PHP 5.1.3.
For further details and definitions of the PHP_INI_* modes, see the Where a configuration setting may be set.

Here's a short explanation of the configuration directives.

gd.jpeg_ignore_warning bool

Ignore warnings (but not errors) created by libjpeg(-turbo).

Changelog for gd.jpeg_ignore_warning
Version Description
7.1.0 The default of gd.jpeg_ignore_warning has been changed from 0 to 1.

See also the exif configuration directives.

Warning

Image functions are very memory intensive. Be sure to set memory_limit high enough, if you are using the bundled version of the GD library.



Resource Types

This extension defines the following resource types:
List of resource types in GD
Name Description Notes
gd Image resource, used by functions like imagecreatefrompng()  
gd font Font resource internally created by imageloadfont()  
gd PS font PostScript Type 1 font resource, returned by imagepsloadfont() Removed as of PHP 7.0.0.
gd PS encoding PostScript Type 1 encoding resource, returned by imagepsencodefont() Removed as of PHP 7.0.0.




Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

GD_VERSION (string)
The GD version PHP was compiled against. (Available as of PHP 5.2.4)
GD_MAJOR_VERSION (integer)
The GD major version PHP was compiled against. (Available as of PHP 5.2.4)
GD_MINOR_VERSION (integer)
The GD minor version PHP was compiled against. (Available as of PHP 5.2.4)
GD_RELEASE_VERSION (integer)
The GD release version PHP was compiled against. (Available as of PHP 5.2.4)
GD_EXTRA_VERSION (string)
The GD "extra" version (beta/rc..) PHP was compiled against. (Available as of PHP 5.2.4)
GD_BUNDLED (integer)
When the bundled version of GD is used this is 1 otherwise its set to 0.
IMG_BMP (integer)
Used as a return value by imagetypes()
IMG_GIF (integer)
Used as a return value by imagetypes()
IMG_JPG (integer)
Used as a return value by imagetypes()
IMG_JPEG (integer)
Used as a return value by imagetypes()

Note:

This constant has the same value as IMG_JPG

IMG_PNG (integer)
Used as a return value by imagetypes()
IMG_WBMP (integer)
Used as a return value by imagetypes()
IMG_XPM (integer)
Used as a return value by imagetypes()
IMG_WEBP (integer)
Used as a return value by imagetypes() Available as of PHP 5.6.25 and PHP 7.0.10, respectively.
IMG_COLOR_TILED (integer)
Special color option which can be used instead of a color allocated with imagecolorallocate() or imagecolorallocatealpha().
IMG_COLOR_STYLED (integer)
Special color option which can be used instead of a color allocated with imagecolorallocate() or imagecolorallocatealpha().
IMG_COLOR_BRUSHED (integer)
Special color option which can be used instead of a color allocated with imagecolorallocate() or imagecolorallocatealpha().
IMG_COLOR_STYLEDBRUSHED (integer)
Special color option which can be used instead of a color allocated with imagecolorallocate() or imagecolorallocatealpha().
IMG_COLOR_TRANSPARENT (integer)
Special color option which can be used instead of a color allocated with imagecolorallocate() or imagecolorallocatealpha().
IMG_AFFINE_TRANSLATE (integer)
An affine transformation type constant used by the imageaffinematrixget() function.
IMG_AFFINE_SCALE (integer)
An affine transformation type constant used by the imageaffinematrixget() function.
IMG_AFFINE_ROTATE (integer)
An affine transformation type constant used by the imageaffinematrixget() function.
IMG_AFFINE_SHEAR_HORIZONTAL (integer)
An affine transformation type constant used by the imageaffinematrixget() function.
IMG_AFFINE_SHEAR_VERTICAL (integer)
An affine transformation type constant used by the imageaffinematrixget() function.
IMG_ARC_ROUNDED (integer)
A style constant used by the imagefilledarc() function.

Note:

This constant has the same value as IMG_ARC_PIE

IMG_ARC_PIE (integer)
A style constant used by the imagefilledarc() function.
IMG_ARC_CHORD (integer)
A style constant used by the imagefilledarc() function.
IMG_ARC_NOFILL (integer)
A style constant used by the imagefilledarc() function.
IMG_ARC_EDGED (integer)
A style constant used by the imagefilledarc() function.
IMG_GD2_RAW (integer)
A type constant used by the imagegd2() function.
IMG_GD2_COMPRESSED (integer)
A type constant used by the imagegd2() function.
IMG_EFFECT_REPLACE (integer)
Alpha blending effect used by the imagelayereffect() function.
IMG_EFFECT_ALPHABLEND (integer)
Alpha blending effect used by the imagelayereffect() function.
IMG_EFFECT_NORMAL (integer)
Alpha blending effect used by the imagelayereffect() function.
IMG_EFFECT_OVERLAY (integer)
Alpha blending effect used by the imagelayereffect() function.
IMG_EFFECT_MULTIPLY (integer)
Alpha blending effect used by the imagelayereffect() function.
IMG_FILTER_NEGATE (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_GRAYSCALE (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_BRIGHTNESS (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_CONTRAST (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_COLORIZE (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_EDGEDETECT (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_GAUSSIAN_BLUR (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_SELECTIVE_BLUR (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_EMBOSS (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_MEAN_REMOVAL (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_SMOOTH (integer)
Special GD filter used by the imagefilter() function.
IMG_FILTER_PIXELATE (integer)
Special GD filter used by the imagefilter() function. (Available as of PHP 5.3.0)
IMG_FILTER_SCATTER (integer)
Special GD filter used by the imagefilter() function. (Available as of PHP 7.4.0)
IMAGETYPE_GIF (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JPEG (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JPEG2000 (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_PNG (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_SWF (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_PSD (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_BMP (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_WBMP (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_XBM (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_TIFF_II (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_TIFF_MM (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_IFF (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JB2 (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JPC (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JP2 (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_JPX (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_SWC (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions.
IMAGETYPE_ICO (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions. (Available as of PHP 5.3.0)
IMAGETYPE_WEBP (integer)
Image type constant used by the image_type_to_mime_type() and image_type_to_extension() functions. (Available as of PHP 7.1.0)
PNG_NO_FILTER (integer)
A special PNG filter, used by the imagepng() function.
PNG_FILTER_NONE (integer)
A special PNG filter, used by the imagepng() function.
PNG_FILTER_SUB (integer)
A special PNG filter, used by the imagepng() function.
PNG_FILTER_UP (integer)
A special PNG filter, used by the imagepng() function.
PNG_FILTER_AVG (integer)
A special PNG filter, used by the imagepng() function.
PNG_FILTER_PAETH (integer)
A special PNG filter, used by the imagepng() function.
PNG_ALL_FILTERS (integer)
A special PNG filter, used by the imagepng() function.
IMG_FLIP_VERTICAL (int)
Used together with imageflip(), available as of PHP 5.5.0.
IMG_FLIP_HORIZONTAL (int)
Used together with imageflip(), available as of PHP 5.5.0.
IMG_FLIP_BOTH (int)
Used together with imageflip(), available as of PHP 5.5.0.
IMG_BELL (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BESSEL (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BILINEAR_FIXED (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BICUBIC (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BICUBIC_FIXED (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BLACKMAN (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BOX (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_BSPLINE (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_CATMULLROM (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_GAUSSIAN (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_GENERALIZED_CUBIC (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_HERMITE (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_HAMMING (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_HANNING (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_MITCHELL (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_POWER (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_QUADRATIC (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_SINC (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_NEAREST_NEIGHBOUR (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_WEIGHTED4 (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.
IMG_TRIANGLE (int)
Used together with imagesetinterpolation(), available as of PHP 5.5.0.


Examples

Table of Contents


PNG creation with PHP

Example #1 PNG creation with PHP

<?php

header
("Content-type: image/png");
$string $_GET['text'];
$im     imagecreatefrompng("images/button1.png");
$orange imagecolorallocate($im22021060);
$px     = (imagesx($im) - 7.5 strlen($string)) / 2;
imagestring($im3$px9$string$orange);
imagepng($im);
imagedestroy($im);

?>
This example would be called from a page with a tag like: <img src="button.php?text=text">. The above button.php script then takes this "text" string and overlays it on top of a base image which in this case is "images/button1.png" and outputs the resulting image. This is a very convenient way to avoid having to draw new button images every time you want to change the text of a button. With this method they are dynamically generated.



Adding watermarks to images using alpha channels

Example #1 Adding watermarks to images using alpha channels

<?php
// Load the stamp and the photo to apply the watermark to
$stamp imagecreatefrompng('stamp.png');
$im imagecreatefromjpeg('photo.jpeg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right 10;
$marge_bottom 10;
$sx imagesx($stamp);
$sy imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $sy $marge_bottom00imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
Adding watermarks to images using alpha channels
This example is a common way to add watermarks and stamps to photos and copyrighted images. Note that the presence of an alpha channel in the stamp image as the text is anti-aliased. This is preserved during copying.



Using imagecopymerge() to create a translucent watermark

Example #1 Using imagecopymerge() to create a translucent watermark

<?php
// Load the stamp and the photo to apply the watermark to
$im imagecreatefromjpeg('photo.jpeg');

// First we create our stamp image manually from GD
$stamp imagecreatetruecolor(10070);
imagefilledrectangle($stamp0099690x0000FF);
imagefilledrectangle($stamp9990600xFFFFFF);
imagestring($stamp52020'libGD'0x0000FF);
imagestring($stamp32040'(c) 2007-9'0x0000FF);

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right 10;
$marge_bottom 10;
$sx imagesx($stamp);
$sy imagesy($stamp);

// Merge the stamp onto our photo with an opacity of 50%
imagecopymerge($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $sy $marge_bottom00imagesx($stamp), imagesy($stamp), 50);

// Save the image to file and free memory
imagepng($im'photo_stamp.png');
imagedestroy($im);

?>
Using imagecopymerge() to create a translucent watermark
This example uses imagecopymerge() to merge the stamp with our original image. Using this we can set the opacity of our stamp - in our example we've set it to 50% opacity. In practice this would be useful in copyright protection as semi-transparent watermarks are hard to remove yet allow viewers to see the image.




GD and Image Functions


gd_info

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

gd_infoRetrieve information about the currently installed GD library

Description

gd_info ( void ) : array

Gets information about the version and capabilities of the installed GD library.

Return Values

Returns an associative array.

Elements of array returned by gd_info()
Attribute Meaning
GD Version string value describing the installed libgd version.
FreeType Support boolean value. TRUE if FreeType Support is installed.
FreeType Linkage string value describing the way in which FreeType was linked. Expected values are: 'with freetype', 'with TTF library', and 'with unknown library'. This element will only be defined if FreeType Support evaluated to TRUE.
T1Lib Support boolean value. TRUE if T1Lib support is included.
GIF Read Support boolean value. TRUE if support for reading GIF images is included.
GIF Create Support boolean value. TRUE if support for creating GIF images is included.
JPEG Support boolean value. TRUE if JPEG support is included.
PNG Support boolean value. TRUE if PNG support is included.
WBMP Support boolean value. TRUE if WBMP support is included.
XBM Support boolean value. TRUE if XBM support is included.
WebP Support boolean value. TRUE if WebP support is included.

Note:

Previous to PHP 5.3.0, the JPEG Support attribute was named JPG Support.

Changelog

Version Description
5.6.12 WebP Support added.
5.3.0 JPG Support attribute renamed to JPEG Support.

Examples

Example #1 Using gd_info()

<?php
var_dump
(gd_info());
?>

The above example will output something similar to:

   array(10) {
     ["GD Version"]=>
     string(24) "bundled (2.1.0 compatible)"
     ["FreeType Support"]=>
     bool(false)
     ["T1Lib Support"]=>
     bool(false)
     ["GIF Read Support"]=>
     bool(true)
     ["GIF Create Support"]=>
     bool(false)
     ["JPEG Support"]=>
     bool(false)
     ["PNG Support"]=>
     bool(true)
     ["WBMP Support"]=>
     bool(true)
     ["XBM Support"]=>
     bool(false)
     ["WebP Support"]=>
     bool(false)
   }
   

See Also



getimagesize

(PHP 4, PHP 5, PHP 7)

getimagesizeGet the size of an image

Description

getimagesize ( string $filename [, array &$imageinfo ] ) : array

The getimagesize() function will determine the size of any supported given image file and return the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag and the correspondent HTTP content type.

getimagesize() can also return some more information in imageinfo parameter.

Caution

This function expects filename to be a valid image file. If a non-image file is supplied, it may be incorrectly detected as an image and the function will return successfully, but the array may contain nonsensical values.

Do not use getimagesize() to check that a given file is a valid image. Use a purpose-built solution such as the Fileinfo extension instead.

Note: Note that JPC and JP2 are capable of having components with different bit depths. In this case, the value for "bits" is the highest bit depth encountered. Also, JP2 files may contain multiple JPEG 2000 codestreams. In this case, getimagesize() returns the values for the first codestream it encounters in the root of the file.

Note: The information about icons are retrieved from the icon with the highest bitrate.

Note: GIF images consist of one or more frames, where each frame may only occupy part of the image. The size of the image which is reported by getimagesize() is the overall size (read from the logical screen descriptor).

Parameters

filename

This parameter specifies the file you wish to retrieve information about. It can reference a local file or (configuration permitting) a remote file using one of the supported streams.

imageinfo

This optional parameter allows you to extract some extended information from the image file. Currently, this will return the different JPG APP markers as an associative array. Some programs use these APP markers to embed text information in images. A very common one is to embed » IPTC information in the APP13 marker. You can use the iptcparse() function to parse the binary APP13 marker into something readable.

Note:

The imageinfo only supports JFIF files.

Return Values

Returns an array with up to 7 elements. Not all image types will include the channels and bits elements.

Index 0 and 1 contains respectively the width and the height of the image.

Note:

Some formats may contain no image or may contain multiple images. In these cases, getimagesize() might not be able to properly determine the image size. getimagesize() will return zero for width and height in these cases.

Index 2 is one of the IMAGETYPE_XXX constants indicating the type of the image.

Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.

mime is the correspondant MIME type of the image. This information can be used to deliver images with the correct HTTP Content-type header:

Example #1 getimagesize() and MIME types

<?php
$size 
getimagesize($filename);
$fp fopen($filename"rb");
if (
$size && $fp) {
    
header("Content-type: {$size['mime']}");
    
fpassthru($fp);
    exit;
} else {
    
// error
}
?>

channels will be 3 for RGB pictures and 4 for CMYK pictures.

bits is the number of bits for each color.

For some image types, the presence of channels and bits values can be a bit confusing. As an example, GIF always uses 3 channels per pixel, but the number of bits per pixel cannot be calculated for an animated GIF with a global color table.

On failure, FALSE is returned.

Errors/Exceptions

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Changelog

Version Description
7.1.0 Added WebP support.
5.3.0 Added icon support.
5.2.3 Read errors generated by this function downgraded to E_NOTICE from E_WARNING.

Examples

Example #2 getimagesize() example

<?php
list($width$height$type$attr) = getimagesize("img/flag.jpg");
echo 
"<img src=\"img/flag.jpg\" $attr alt=\"getimagesize() example\" />";
?>

Example #3 getimagesize (URL)

<?php
$size 
getimagesize("http://www.example.com/gifs/logo.gif");

// if the file name has space in it, encode it properly
$size getimagesize("http://www.example.com/gifs/lo%20go.gif");

?>

Example #4 getimagesize() returning IPTC

<?php
$size 
getimagesize("testimg.jpg"$info);
if (isset(
$info["APP13"])) {
    
$iptc iptcparse($info["APP13"]);
    
var_dump($iptc);
}
?>

Notes

Note:

This function does not require the GD image library.

See Also



getimagesizefromstring

(PHP 5 >= 5.4.0, PHP 7)

getimagesizefromstringGet the size of an image from a string

Description

getimagesizefromstring ( string $imagedata [, array &$imageinfo ] ) : array

Identical to getimagesize() except that getimagesizefromstring() accepts a string instead of a file name as the first parameter.

See the getimagesize() documentation for details on how this function works.

Parameters

imagedata

The image data, as a string.

imageinfo

See getimagesize().

Return Values

See getimagesize().

Examples

Example #1 getimagesizefromstring() example

<?php
$img 
'/path/to/test.png';

// Open as a file
$size_info1 getimagesize($img);

// Or open as a string
$data       file_get_contents($img);
$size_info2 getimagesizefromstring($data);
?>

See Also



image_type_to_extension

(PHP 5 >= 5.2.0, PHP 7)

image_type_to_extensionGet file extension for image type

Description

image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] ) : string

Returns the extension for the given IMAGETYPE_XXX constant.

Parameters

imagetype

One of the IMAGETYPE_XXX constant.

include_dot

Whether to prepend a dot to the extension or not. Default to TRUE.

Return Values

A string with the extension corresponding to the given image type.

Examples

Example #1 image_type_to_extension() example

<?php
// Create image instance
$im imagecreatetruecolor(100100);

// Save image
imagepng($im'./test' image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>

Notes

Note:

This function does not require the GD image library.



image_type_to_mime_type

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

image_type_to_mime_typeGet Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype

Description

image_type_to_mime_type ( int $imagetype ) : string

The image_type_to_mime_type() function will determine the Mime-Type for an IMAGETYPE constant.

Parameters

imagetype

One of the IMAGETYPE_XXX constants.

Return Values

The returned values are as follows
Returned values Constants
imagetype Returned value
IMAGETYPE_GIF image/gif
IMAGETYPE_JPEG image/jpeg
IMAGETYPE_PNG image/png
IMAGETYPE_SWF application/x-shockwave-flash
IMAGETYPE_PSD image/psd
IMAGETYPE_BMP image/bmp
IMAGETYPE_TIFF_II (intel byte order) image/tiff
IMAGETYPE_TIFF_MM (motorola byte order) image/tiff
IMAGETYPE_JPC application/octet-stream
IMAGETYPE_JP2 image/jp2
IMAGETYPE_JPX application/octet-stream
IMAGETYPE_JB2 application/octet-stream
IMAGETYPE_SWC application/x-shockwave-flash
IMAGETYPE_IFF image/iff
IMAGETYPE_WBMP image/vnd.wap.wbmp
IMAGETYPE_XBM image/xbm
IMAGETYPE_ICO image/vnd.microsoft.icon
IMAGETYPE_WEBP image/webp

Examples

Example #1 image_type_to_mime_type() example

<?php
header
("Content-type: " image_type_to_mime_type(IMAGETYPE_PNG));
?>

Notes

Note:

This function does not require the GD image library.

See Also



image2wbmp

(PHP 4 >= 4.0.5, PHP 5, PHP 7)

image2wbmpOutput image to browser or file

Warning

image2wbmp() is deprecated as of PHP 7.3.0, and will be removed in the next major version. Use imagewbmp() instead.

Description

image2wbmp ( resource $image [, string $filename [, int $foreground ]] ) : bool

image2wbmp() outputs or save a WBMP version of the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

filename

Path to the saved file. If not given, the raw image stream will be output directly.

foreground

You can set the foreground color with this parameter by setting an identifier obtained from imagecolorallocate(). The default foreground color is black.

Return Values

Returns TRUE on success or FALSE on failure.

Caution

However, if libgd fails to output the image, this function returns TRUE.

Examples

Example #1 image2wbmp() example

<?php
$file 
'php.png';
$image imagecreatefrompng($file);

header('Content-Type: ' image_type_to_mime_type(IMAGETYPE_WBMP));
image2wbmp($image); // output the stream directly
imagedestroy($image);
?>

See Also



imageaffine

(PHP 5 >= 5.5.0, PHP 7)

imageaffineReturn an image containing the affine transformed src image, using an optional clipping area

Description

imageaffine ( resource $image , array $affine [, array $clip ] ) : resource

Warning

This function is currently not documented; only its argument list is available.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

affine

Array with keys 0 to 5.

clip

Array with keys "x", "y", "width" and "height".

Return Values

Return affined image resource on success or FALSE on failure.



imageaffinematrixconcat

(PHP 5 >= 5.5.0, PHP 7)

imageaffinematrixconcatConcatenate two affine transformation matrices

Description

imageaffinematrixconcat ( array $m1 , array $m2 ) : array

Returns the concatenation of two affine transformation matrices, what is useful if multiple transformations should be applied to the same image in one go.

Parameters

m1

An affine transformation matrix (an array with keys 0 to 5 and float values).

m2

An affine transformation matrix (an array with keys 0 to 5 and float values).

Return Values

An affine transformation matrix (an array with keys 0 to 5 and float values) or FALSE on failure.

Examples

Example #1 imageaffinematrixconcat() example

<?php
$m1 
imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' 2'y' => 3));
$m2 imageaffinematrixget(IMG_AFFINE_SCALE, array('x' 4'y' => 5));
$matrix imageaffinematrixconcat($m1$m2);
print_r($matrix);
?>

The above example will output:

   Array
   (
       [0] => 4
       [1] => 0
       [2] => 0
       [3] => 5
       [4] => 8
       [5] => 15
   )
   

See Also



imageaffinematrixget

(PHP 5 >= 5.5.0, PHP 7)

imageaffinematrixgetGet an affine transformation matrix

Description

imageaffinematrixget ( int $type [, mixed $options ] ) : array

Returns an affine transformation matrix.

Parameters

type

One of the IMG_AFFINE_* constants.

options

If type is IMG_AFFINE_TRANSLATE or IMG_AFFINE_SCALE, options has to be an array with keys x and y, both having float values.

If type is IMG_AFFINE_ROTATE, IMG_AFFINE_SHEAR_HORIZONTAL or IMG_AFFINE_SHEAR_VERTICAL, options has to be a float specifying the angle.

Return Values

An affine transformation matrix (an array with keys 0 to 5 and float values) or FALSE on failure.

Examples

Example #1 imageaffinematrixget() example

<?php
$matrix 
imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' 2'y' => 3));
print_r($matrix);
?>

The above example will output:

   Array
   (
       [0] => 1
       [1] => 0
       [2] => 0
       [3] => 1
       [4] => 2
       [5] => 3
   )
   

See Also



imagealphablending

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagealphablendingSet the blending mode for an image

Description

imagealphablending ( resource $image , bool $blendmode ) : bool

imagealphablending() allows for two different modes of drawing on truecolor images. In blending mode, the alpha channel component of the color supplied to all drawing function, such as imagesetpixel() determines how much of the underlying color should be allowed to shine through. As a result, gd automatically blends the existing color at that point with the drawing color, and stores the result in the image. The resulting pixel is opaque. In non-blending mode, the drawing color is copied literally with its alpha channel information, replacing the destination pixel. Blending mode is not available when drawing on palette images.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

blendmode

Whether to enable the blending mode or not. On true color images the default value is TRUE otherwise the default value is FALSE

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagealphablending() usage example

<?php
// Create image
$im imagecreatetruecolor(100100);

// Set alphablending to on
imagealphablending($imtrue);

// Draw a square
imagefilledrectangle($im30307070imagecolorallocate($im25500));

// Output
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>


imageantialias

(PHP 4 >= 4.3.2, PHP 5, PHP 7)

imageantialiasShould antialias functions be used or not

Description

imageantialias ( resource $image , bool $enabled ) : bool

Activate the fast drawing antialiased methods for lines and wired polygons. It does not support alpha components. It works using a direct blend operation. It works only with truecolor images.

Thickness and styled are not supported.

Using antialiased primitives with transparent background color can end with some unexpected results. The blend method uses the background color as any other colors. The lack of alpha component support does not allow an alpha based antialiasing method.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

enabled

Whether to enable antialiasing or not.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.2.0 imageantialias() is now generally available. Formerly it was only available if PHP was compiled with the bundled version of the GD library.

Examples

Example #1 A comparison of two lines, one with anti-aliasing switched on

<?php
// Setup an anti-aliased image and a normal image
$aa imagecreatetruecolor(400100);
$normal imagecreatetruecolor(200100);

// Switch antialiasing on for one image
imageantialias($aatrue);

// Allocate colors
$red imagecolorallocate($normal25500);
$red_aa imagecolorallocate($aa25500);

// Draw two lines, one with AA enabled
imageline($normal00200100$red);
imageline($aa00200100$red_aa);

// Merge the two images side by side for output (AA: left, Normal: Right)
imagecopymerge($aa$normal200000200100100);

// Output image
header('Content-type: image/png');

imagepng($aa);
imagedestroy($aa);
imagedestroy($normal);
?>

The above example will output something similar to:

Output of example : A comparison of two lines, one with anti-aliasing switched on

See Also



imagearc

(PHP 4, PHP 5, PHP 7)

imagearcDraws an arc

Description

imagearc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color ) : bool

imagearc() draws an arc of circle centered at the given coordinates.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

cx

x-coordinate of the center.

cy

y-coordinate of the center.

width

The arc width.

height

The arc height.

start

The arc start angle, in degrees.

end

The arc end angle, in degrees. 0° is located at the three-o'clock position, and the arc is drawn clockwise.

color

A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Drawing a circle with imagearc()

<?php

// create a 200*200 image
$img imagecreatetruecolor(200200);

// allocate some colors
$white imagecolorallocate($img255255255);
$red   imagecolorallocate($img255,   0,   0);
$green imagecolorallocate($img,   0255,   0);
$blue  imagecolorallocate($img,   0,   0255);

// draw the head
imagearc($img100100200200,  0360$white);
// mouth
imagearc($img10010015015025155$red);
// left and then the right eye
imagearc($img,  60,  75,  50,  50,  0360$green);
imagearc($img140,  75,  50,  50,  0360$blue);

// output image in the browser
header("Content-type: image/png");
imagepng($img);

// free memory
imagedestroy($img);

?>

The above example will output something similar to:

Output of example : Drawing a circle with imagearc()

See Also



imagebmp

(PHP 7 >= 7.2.0)

imagebmpOutput a BMP image to browser or file

Description

imagebmp ( resource $image [, mixed $to = NULL [, bool $compressed = TRUE ]] ) : bool

Outputs or saves a BMP version of the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

to

The path or an open stream resource (which is automatically being closed after this function returns) to save the file to. If not set or NULL, the raw image stream will be outputted directly.

Note:

NULL is invalid if the compressed arguments is not used.

compressed

Whether the BMP should be compressed with run-length encoding (RLE), or not.

Return Values

Returns TRUE on success or FALSE on failure.

Caution

However, if libgd fails to output the image, this function returns TRUE.

Examples

Example #1 Saving a BMP file

<?php
// Create a blank image and add some text
$im imagecreatetruecolor(12020);
$text_color imagecolorallocate($im2331491);

imagestring($im155,  'BMP with PHP'$text_color);

// Save the image
imagebmp($im'php.bmp');

// Free up memory
imagedestroy($im);
?>



imagechar

(PHP 4, PHP 5, PHP 7)

imagecharDraw a character horizontally

Description

imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color ) : bool

imagechar() draws the first character of c in the image identified by image with its upper-left at x,y (top left is 0, 0) with the color color.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

font

Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

x

x-coordinate of the start.

y

y-coordinate of the start.

c

The character to draw.

color

A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagechar() example

<?php

$im 
imagecreate(100100);

$string 'PHP';

$bg imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

// prints a black "P" in the top left corner
imagechar($im100$string$black);

header('Content-type: image/png');
imagepng($im);

?>

The above example will output something similar to:

Output of example : imagechar()

See Also



imagecharup

(PHP 4, PHP 5, PHP 7)

imagecharupDraw a character vertically

Description

imagecharup ( resource $image , int $font , int $x , int $y , string $c , int $color ) : bool

Draws the character c vertically at the specified coordinate on the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

font

Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

x

x-coordinate of the start.

y

y-coordinate of the start.

c

The character to draw.

color

A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagecharup() example

<?php

$im 
imagecreate(100100);

$string 'Note that the first letter is a N';

$bg imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

// prints a black "Z" on a white background
imagecharup($im31010$string$black);

header('Content-type: image/png');
imagepng($im);

?>

The above example will output something similar to:

Output of example : imagecharup()

See Also



imagecolorallocate

(PHP 4, PHP 5, PHP 7)

imagecolorallocateAllocate a color for an image

Description

imagecolorallocate ( resource $image , int $red , int $green , int $blue ) : int

Returns a color identifier representing the color composed of the given RGB components.

imagecolorallocate() must be called to create each color that is to be used in the image represented by image.

Note:

The first call to imagecolorallocate() fills the background color in palette-based images - images created using imagecreate().

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

These parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

A color identifier or FALSE if the allocation failed.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Changelog

Version Description
5.1.3 Returns FALSE if the allocation failed. Previously -1 was returned.

Examples

Example #1 imagecolorallocate() example

<?php

$im 
imagecreate(100100);

// sets background to red
$background imagecolorallocate($im25500);

// sets some colors
$white imagecolorallocate($im255255255);
$black imagecolorallocate($im000);

// hexadecimal way
$white imagecolorallocate($im0xFF0xFF0xFF);
$black imagecolorallocate($im0x000x000x00);

?>

See Also



imagecolorallocatealpha

(PHP 4 >= 4.3.2, PHP 5, PHP 7)

imagecolorallocatealphaAllocate a color for an image

Description

imagecolorallocatealpha ( resource $image , int $red , int $green , int $blue , int $alpha ) : int

imagecolorallocatealpha() behaves identically to imagecolorallocate() with the addition of the transparency parameter alpha.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

alpha

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

The red, green and blue parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

A color identifier or FALSE if the allocation failed.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Changelog

Version Description
5.1.3 Returns FALSE if the allocation failed. Previously -1 was returned.

Examples

Example #1 Example of using imagecolorallocatealpha()

<?php
$size 
300;
$image=imagecreatetruecolor($size$size);

// something to get a white background with black border
$back imagecolorallocate($image255255255);
$border imagecolorallocate($image000);
imagefilledrectangle($image00$size 1$size 1$back);
imagerectangle($image00$size 1$size 1$border);

$yellow_x 100;
$yellow_y 75;
$red_x    120;
$red_y    165;
$blue_x   187;
$blue_y   125;
$radius   150;

// allocate colors with alpha values
$yellow imagecolorallocatealpha($image255255075);
$red    imagecolorallocatealpha($image2550075);
$blue   imagecolorallocatealpha($image0025575);

// drawing 3 overlapped circle
imagefilledellipse($image$yellow_x$yellow_y$radius$radius$yellow);
imagefilledellipse($image$red_x$red_y$radius$radius$red);
imagefilledellipse($image$blue_x$blue_y$radius$radius$blue);

// don't forget to output a correct header!
header('Content-Type: image/png');

// and finally, output the result
imagepng($image);
imagedestroy($image);
?>

The above example will output something similar to:

Output of example : Example of using imagecolorallocatealpha()

Example #2 Convert typical alpha values for use with imagecolorallocatealpha()

Usually alpha values of 0 designate fully transparent pixels, and the alpha channel has 8 bits. To convert such alpha values to be compatible with imagecolorallocatealpha(), some simple arithmetic is sufficient:

<?php
$alpha8 
0// fully transparent
var_dump(127 - ($alpha8 >> 1));
$alpha8 255// fully opaque
var_dump(127 - ($alpha8 >> 1));
?>

The above example will output:

   int(127)
   int(0)
   

See Also



imagecolorat

(PHP 4, PHP 5, PHP 7)

imagecoloratGet the index of the color of a pixel

Description

imagecolorat ( resource $image , int $x , int $y ) : int

Returns the index of the color of the pixel at the specified location in the image specified by image.

If the image is a truecolor image, this function returns the RGB value of that pixel as integer. Use bitshifting and masking to access the distinct red, green and blue component values:

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x

x-coordinate of the point.

y

y-coordinate of the point.

Return Values

Returns the index of the color or FALSE on failure.

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Examples

Example #1 Access distinct RGB values

<?php
$im 
imagecreatefrompng("php.png");
$rgb imagecolorat($im1015);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b $rgb 0xFF;

var_dump($r$g$b);
?>

The above example will output something similar to:

   int(119)
   int(123)
   int(180)
   

Example #2 Human-readable RGB values using imagecolorsforindex()

<?php
$im 
imagecreatefrompng("php.png");
$rgb imagecolorat($im1015);

$colors imagecolorsforindex($im$rgb);

var_dump($colors);
?>

The above example will output something similar to:

   array(4) {
     ["red"]=>
     int(119)
     ["green"]=>
     int(123)
     ["blue"]=>
     int(180)
     ["alpha"]=>
     int(127)
   }
   

See Also



imagecolorclosest

(PHP 4, PHP 5, PHP 7)

imagecolorclosestGet the index of the closest color to the specified color

Description

imagecolorclosest ( resource $image , int $red , int $green , int $blue ) : int

Returns the index of the color in the palette of the image which is "closest" to the specified RGB value.

The "distance" between the desired color and each color in the palette is calculated as if the RGB values represented points in three-dimensional space.

If you created the image from a file, only colors used in the image are resolved. Colors present only in the palette are not resolved.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

Returns the index of the closest color, in the palette of the image, to the specified one

Examples

Example #1 Search for a set of colors in an image

<?php
// Start with an image and convert it to a palette-based image
$im imagecreatefrompng('figures/imagecolorclosest.png');
imagetruecolortopalette($imfalse255);

// Search colors (RGB)
$colors = array(
    array(
254145154),
    array(
153145188),
    array(
15390145),
    array(
25513792)
);

// Loop through each search and find the closest color in the palette.
// Return the search number, the search RGB and the converted RGB match
foreach($colors as $id => $rgb)
{
    
$result imagecolorclosest($im$rgb[0], $rgb[1], $rgb[2]);
    
$result imagecolorsforindex($im$result);
    
$result "({$result['red']}{$result['green']}{$result['blue']})";

    echo 
"#$id: Search ($rgb[0]$rgb[1]$rgb[2]); Closest match: $result.\n";
}

imagedestroy($im);
?>

The above example will output something similar to:

   #0: Search (254, 145, 154); Closest match: (252, 150, 148).
   #1: Search (153, 145, 188); Closest match: (148, 150, 196).
   #2: Search (153, 90, 145); Closest match: (148, 90, 156).
   #3: Search (255, 137, 92); Closest match: (252, 150, 92).
   

See Also



imagecolorclosestalpha

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecolorclosestalphaGet the index of the closest color to the specified color + alpha

Description

imagecolorclosestalpha ( resource $image , int $red , int $green , int $blue , int $alpha ) : int

Returns the index of the color in the palette of the image which is "closest" to the specified RGB value and alpha level.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

alpha

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

Returns the index of the closest color in the palette.

Examples

Example #1 Search for a set of colors in an image

<?php
// Start with an image and convert it to a palette-based image
$im imagecreatefrompng('figures/imagecolorclosest.png');
imagetruecolortopalette($imfalse255);

// Search colors (RGB)
$colors = array(
    array(
25414515450),
    array(
153145188127),
    array(
153901450),
    array(
2551379284)
);

// Loop through each search and find the closest color in the palette.
// Return the search number, the search RGB and the converted RGB match
foreach($colors as $id => $rgb)
{
    
$result imagecolorclosestalpha($im$rgb[0], $rgb[1], $rgb[2], $rgb[3]);
    
$result imagecolorsforindex($im$result);
    
$result "({$result['red']}{$result['green']}{$result['blue']}{$result['alpha']})";

    echo 
"#$id: Search ($rgb[0]$rgb[1]$rgb[2]$rgb[3]); Closest match: $result.\n";
}

imagedestroy($im);
?>

The above example will output something similar to:

   #0: Search (254, 145, 154, 50); Closest match: (252, 150, 148, 0).
   #1: Search (153, 145, 188, 127); Closest match: (148, 150, 196, 0).
   #2: Search (153, 90, 145, 0); Closest match: (148, 90, 156, 0).
   #3: Search (255, 137, 92, 84); Closest match: (252, 150, 92, 0).
   

See Also



imagecolorclosesthwb

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagecolorclosesthwbGet the index of the color which has the hue, white and blackness

Description

imagecolorclosesthwb ( resource $image , int $red , int $green , int $blue ) : int

Get the index of the color which has the hue, white and blackness nearest the given color.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

Return Values

Returns an integer with the index of the color which has the hue, white and blackness nearest the given color.

Changelog

Version Description
5.3.0 This function is now available on Windows

Examples

Example #1 Example of using imagecolorclosesthwb()

<?php
$im 
imagecreatefromgif('php.gif');

echo 
'HWB: ' imagecolorclosesthwb($im116115152);

imagedestroy($im);
?>

The above example will output something similar to:

   HWB: 33
   

See Also



imagecolordeallocate

(PHP 4, PHP 5, PHP 7)

imagecolordeallocateDe-allocate a color for an image

Description

imagecolordeallocate ( resource $image , int $color ) : bool

De-allocates a color previously allocated with imagecolorallocate() or imagecolorallocatealpha().

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

color

The color identifier.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Using imagecolordeallocate()

<?php
$white 
imagecolorallocate($im255255255);
imagecolordeallocate($im$white);
?>

See Also



imagecolorexact

(PHP 4, PHP 5, PHP 7)

imagecolorexactGet the index of the specified color

Description

imagecolorexact ( resource $image , int $red , int $green , int $blue ) : int

Returns the index of the specified color in the palette of the image.

If you created the image from a file, only colors used in the image are resolved. Colors present only in the palette are not resolved.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

Return Values

Returns the index of the specified color in the palette, or -1 if the color does not exist.

Examples

Example #1 Get colors from the GD logo

<?php
// Setup an image
$im imagecreatefrompng('./gdlogo.png');

$colors   = Array();
$colors[] = imagecolorexact($im25500);
$colors[] = imagecolorexact($im000);
$colors[] = imagecolorexact($im255255255);
$colors[] = imagecolorexact($im10025552);

print_r($colors);

// Free from memory
imagedestroy($im);
?>

The above example will output something similar to:

   Array
   (
       [0] => 16711680
       [1] => 0
       [2] => 16777215
       [3] => 6618932
   )
   

See Also



imagecolorexactalpha

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecolorexactalphaGet the index of the specified color + alpha

Description

imagecolorexactalpha ( resource $image , int $red , int $green , int $blue , int $alpha ) : int

Returns the index of the specified color+alpha in the palette of the image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

alpha

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

Returns the index of the specified color+alpha in the palette of the image, or -1 if the color does not exist in the image's palette.

Examples

Example #1 Get colors from the GD logo

<?php

// Setup an image
$im imagecreatefrompng('./gdlogo.png');

$colors   = Array();
$colors[] = imagecolorexactalpha($im255000);
$colors[] = imagecolorexactalpha($im000127);
$colors[] = imagecolorexactalpha($im25525525555);
$colors[] = imagecolorexactalpha($im1002555220);

print_r($colors);

// Free from memory
imagedestroy($im);
?>

The above example will output something similar to:

   Array
   (
       [0] => 16711680
       [1] => 2130706432
       [2] => 939524095
       [3] => 342163252
   )
   

See Also



imagecolormatch

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

imagecolormatchMakes the colors of the palette version of an image more closely match the true color version

Description

imagecolormatch ( resource $image1 , resource $image2 ) : bool

Makes the colors of the palette version of an image more closely match the true color version.

Parameters

image1

A truecolor image resource.

image2

A palette image resource pointing to an image that has the same size as image1.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagecolormatch() example

<?php
// Setup the true color and palette images
$im1 imagecreatefrompng('./gdlogo.png');
$im2 imagecreate(imagesx($im1), imagesy($im1));

// Add some colors to $im2
$colors   = Array();
$colors[] = imagecolorallocate($im22553674);
$colors[] = imagecolorallocate($im2400240);
$colors[] = imagecolorallocate($im282100255);
$colors[] = imagecolorallocate($im2846344);

// Match these colors with the true color image
imagecolormatch($im1$im2);

// Free from memory
imagedestroy($im1);
imagedestroy($im2);
?>

See Also



imagecolorresolve

(PHP 4, PHP 5, PHP 7)

imagecolorresolveGet the index of the specified color or its closest possible alternative

Description

imagecolorresolve ( resource $image , int $red , int $green , int $blue ) : int

This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.

If you created the image from a file, only colors used in the image are resolved. Colors present only in the palette are not resolved.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

Return Values

Returns a color index.

Examples

Example #1 Using imagecoloresolve() to get colors from an image

<?php
// Load an image
$im imagecreatefromgif('phplogo.gif');

// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolve($im255255255);
$colors[] = imagecolorresolve($im00200);

// Output
print_r($colors);

imagedestroy($im);
?>

The above example will output something similar to:

   Array
   (
       [0] => 89
       [1] => 85
   )
   

See Also



imagecolorresolvealpha

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecolorresolvealphaGet the index of the specified color + alpha or its closest possible alternative

Description

imagecolorresolvealpha ( resource $image , int $red , int $green , int $blue , int $alpha ) : int

This function is guaranteed to return a color index for a requested color, either the exact color or the closest possible alternative.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

alpha

A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

The colors parameters are integers between 0 and 255 or hexadecimals between 0x00 and 0xFF.

Return Values

Returns a color index.

Examples

Example #1 Using imagecoloresolvealpha() to get colors from an image

<?php
// Load an image
$im imagecreatefromgif('phplogo.gif');

// Get closest colors from the image
$colors = array();
$colors[] = imagecolorresolvealpha($im2552552550);
$colors[] = imagecolorresolvealpha($im00200127);

// Output
print_r($colors);

imagedestroy($im);
?>

The above example will output something similar to:

   Array
   (
       [0] => 89
       [1] => 85
   )
   

See Also



imagecolorset

(PHP 4, PHP 5, PHP 7)

imagecolorsetSet the color for the specified palette index

Description

imagecolorset ( resource $image , int $index , int $red , int $green , int $blue [, int $alpha = 0 ] ) : void

This sets the specified index in the palette to the specified color. This is useful for creating flood-fill-like effects in palleted images without the overhead of performing the actual flood-fill.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

index

An index in the palette.

red

Value of red component.

green

Value of green component.

blue

Value of blue component.

alpha

Value of alpha component.

Return Values

No value is returned.

Changelog

Version Description
5.4.0 The alpha parameter was added.

Examples

Example #1 imagecolorset() example

<?php
// Create a 300x100 image
$im imagecreate(300100);

// Set the background to be red
imagecolorallocate($im25500);

// Get the color index for the background
$bg imagecolorat($im00);

// Set the backgrund to be blue
imagecolorset($im$bg00255);

// Output the image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

See Also



imagecolorsforindex

(PHP 4, PHP 5, PHP 7)

imagecolorsforindexGet the colors for an index

Description

imagecolorsforindex ( resource $image , int $index ) : array

Gets the color for a specified index.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

index

The color index.

Return Values

Returns an associative array with red, green, blue and alpha keys that contain the appropriate values for the specified color index.

Examples

Example #1 imagecolorsforindex() example

<?php

// open an image
$im imagecreatefrompng('nexen.png');

// get a color
$start_x 40;
$start_y 50;
$color_index imagecolorat($im$start_x$start_y);

// make it human readable
$color_tran imagecolorsforindex($im$color_index);

// what is it ?
print_r($color_tran);

?>

The above example will output something similar to:

   Array
   (
      [red] => 226
      [green] => 222
      [blue] => 252
      [alpha] => 0
   )
   

See Also



imagecolorstotal

(PHP 4, PHP 5, PHP 7)

imagecolorstotalFind out the number of colors in an image's palette

Description

imagecolorstotal ( resource $image ) : int

Returns the number of colors in an image palette.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

Return Values

Returns the number of colors in the specified image's palette or 0 for truecolor images.

Examples

Example #1 Getting total number of colors in an image using imagecolorstotal()

<?php
// Create image instance
$im imagecreatefromgif('php.gif');

echo 
'Total colors in image: ' imagecolorstotal($im);

// Free image
imagedestroy($im);
?>

The above example will output something similar to:

   Total colors in image: 128
   

See Also



imagecolortransparent

(PHP 4, PHP 5, PHP 7)

imagecolortransparentDefine a color as transparent

Description

imagecolortransparent ( resource $image ) : int
imagecolortransparent ( resource $image , int $color ) : int

Gets or sets the transparent color in the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

color

A color identifier created with imagecolorallocate().

Return Values

The identifier of the new (or current, if none is specified) transparent color is returned. If color is not specified, and the image has no transparent color, the returned identifier will be -1.

Examples

Example #1 imagecolortransparent() example

<?php
// Create a 55x30 image
$im imagecreatetruecolor(5530);
$red imagecolorallocate($im25500);
$black imagecolorallocate($im000);

// Make the background transparent
imagecolortransparent($im$black);

// Draw a red rectangle
imagefilledrectangle($im445025$red);

// Save the image
imagepng($im'./imagecolortransparent.png');
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : imagecolortransparent()

Notes

Note:

Transparency is copied only with imagecopymerge() and true color images, not with imagecopy() or pallete images.

Note:

The transparent color is a property of the image, transparency is not a property of the color. Once you have set a color to be the transparent color, any regions of the image in that color that were drawn previously will be transparent.



imageconvolution

(PHP 5 >= 5.1.0, PHP 7)

imageconvolutionApply a 3x3 convolution matrix, using coefficient and offset

Description

imageconvolution ( resource $image , array $matrix , float $div , float $offset ) : bool

Applies a convolution matrix on the image, using the given coefficient and offset.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

matrix

A 3x3 matrix: an array of three arrays of three floats.

div

The divisor of the result of the convolution, used for normalization.

offset

Color offset.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Embossing the PHP.net logo

<?php
$image 
imagecreatefromgif('http://www.php.net/images/php.gif');

$emboss = array(array(200), array(0, -10), array(00, -1));
imageconvolution($image$emboss1127);

header('Content-Type: image/png');
imagepng($imagenull9);
?>

The above example will output:

Output of example : Embossing the PHP.net logo

Example #2 Gaussian blur

<?php
$image 
imagecreatetruecolor(180,40);

// Writes the text and apply a gaussian blur on the image
imagestring($image5108'Gaussian Blur Text'0x00ff00);
$gaussian = array(array(1.02.01.0), array(2.04.02.0), array(1.02.01.0));
imageconvolution($image$gaussian160);

// Rewrites the text for comparison
imagestring($image51018'Gaussian Blur Text'0x00ff00);

header('Content-Type: image/png');
imagepng($imagenull9);
?>

The above example will output:

Output of example : Gaussian blur

Notes

This function requires GD 2.1.0 or higher.

See Also



imagecopy

(PHP 4, PHP 5, PHP 7)

imagecopyCopy part of an image

Description

imagecopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h ) : bool

Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

Parameters

dst_im

Destination image resource.

src_im

Source image resource.

dst_x

x-coordinate of destination point.

dst_y

y-coordinate of destination point.

src_x

x-coordinate of source point.

src_y

y-coordinate of source point.

src_w

Source width.

src_h

Source height.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Cropping the PHP.net logo

<?php
// Create image instances
$src imagecreatefromgif('php.gif');
$dest imagecreatetruecolor(8040);

// Copy
imagecopy($dest$src0020138040);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);
?>

The above example will output something similar to:

Output of example : Cropping the PHP.net logo



imagecopymerge

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagecopymergeCopy and merge part of an image

Description

imagecopymerge ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) : bool

Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

Parameters

dst_im

Destination image resource.

src_im

Source image resource.

dst_x

x-coordinate of destination point.

dst_y

y-coordinate of destination point.

src_x

x-coordinate of source point.

src_y

y-coordinate of source point.

src_w

Source width.

src_h

Source height.

pct

The two images will be merged according to pct which can range from 0 to 100. When pct = 0, no action is taken, when 100 this function behaves identically to imagecopy() for pallete images, except for ignoring alpha components, while it implements alpha transparency for true colour images.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Merging two copies of the PHP.net logo with 75% transparency

<?php
// Create image instances
$dest imagecreatefromgif('php.gif');
$src imagecreatefromgif('php.gif');

// Copy and merge
imagecopymerge($dest$src1010001004775);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);
?>



imagecopymergegray

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecopymergegrayCopy and merge part of an image with gray scale

Description

imagecopymergegray ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h , int $pct ) : bool

imagecopymergegray() copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.

This function is identical to imagecopymerge() except that when merging it preserves the hue of the source by converting the destination pixels to gray scale before the copy operation.

Parameters

dst_im

Destination image resource.

src_im

Source image resource.

dst_x

x-coordinate of destination point.

dst_y

y-coordinate of destination point.

src_x

x-coordinate of source point.

src_y

y-coordinate of source point.

src_w

Source width.

src_h

Source height.

pct

The src_im will be changed to grayscale according to pct where 0 is fully grayscale and 100 is unchanged. When pct = 100 this function behaves identically to imagecopy() for pallete images, except for ignoring alpha components, while it implements alpha transparency for true colour images.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagecopymergegray() usage

<?php
// Create image instances
$dest imagecreatefromgif('php.gif');
$src imagecreatefromgif('php.gif');

// Copy and merge - Gray = 20%
imagecopymergegray($dest$src1010001004720);

// Output and free from memory
header('Content-Type: image/gif');
imagegif($dest);

imagedestroy($dest);
imagedestroy($src);
?>



imagecopyresampled

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecopyresampledCopy and resize part of an image with resampling

Description

imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool

imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.

In other words, imagecopyresampled() will take a rectangular area from src_image of width src_w and height src_h at position (src_x,src_y) and place it in a rectangular area of dst_image of width dst_w and height dst_h at position (dst_x,dst_y).

If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.

Parameters

dst_image

Destination image resource.

src_image

Source image resource.

dst_x

x-coordinate of destination point.

dst_y

y-coordinate of destination point.

src_x

x-coordinate of source point.

src_y

y-coordinate of source point.

dst_w

Destination width.

dst_h

Destination height.

src_w

Source width.

src_h

Source height.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Simple example

This example will resample an image to half its original size.

<?php
// The file
$filename 'test.jpg';
$percent 0.5;

// Content type
header('Content-Type: image/jpeg');

// Get new dimensions
list($width$height) = getimagesize($filename);
$new_width $width $percent;
$new_height $height $percent;

// Resample
$image_p imagecreatetruecolor($new_width$new_height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$new_width$new_height$width$height);

// Output
imagejpeg($image_pnull100);
?>

The above example will output something similar to:

Output of example : Simple example

Example #2 Resampling an image proportionally

This example will display an image with the maximum width, or height, of 200 pixels.

<?php
// The file
$filename 'test.jpg';

// Set a maximum height and width
$width 200;
$height 200;

// Content type
header('Content-Type: image/jpeg');

// Get new dimensions
list($width_orig$height_orig) = getimagesize($filename);

$ratio_orig $width_orig/$height_orig;

if (
$width/$height $ratio_orig) {
   
$width $height*$ratio_orig;
} else {
   
$height $width/$ratio_orig;
}

// Resample
$image_p imagecreatetruecolor($width$height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$width$height$width_orig$height_orig);

// Output
imagejpeg($image_pnull100);
?>

The above example will output something similar to:

Output of example : Resampling an image proportionally

Notes

Note:

There is a problem due to palette image limitations (255+1 colors). Resampling or filtering an image commonly needs more colors than 255, a kind of approximation is used to calculate the new resampled pixel and its color. With a palette image we try to allocate a new color, if that failed, we choose the closest (in theory) computed color. This is not always the closest visual color. That may produce a weird result, like blank (or visually blank) images. To skip this problem, please use a truecolor image as a destination image, such as one created by imagecreatetruecolor().

See Also

imagecopyresized() - Copy and resize part of an image imagescale() - Scale an image using the given new width and height



imagecopyresized

(PHP 4, PHP 5, PHP 7)

imagecopyresizedCopy and resize part of an image

Description

imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool

imagecopyresized() copies a rectangular portion of one image to another image. dst_image is the destination image, src_image is the source image identifier.

In other words, imagecopyresized() will take a rectangular area from src_image of width src_w and height src_h at position (src_x,src_y) and place it in a rectangular area of dst_image of width dst_w and height dst_h at position (dst_x,dst_y).

If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable.

Parameters

dst_image

Destination image resource.

src_image

Source image resource.

dst_x

x-coordinate of destination point.

dst_y

y-coordinate of destination point.

src_x

x-coordinate of source point.

src_y

y-coordinate of source point.

dst_w

Destination width.

dst_h

Destination height.

src_w

Source width.

src_h

Source height.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Resizing an image

This example will display the image at half size.

<?php
// File and new size
$filename 'test.jpg';
$percent 0.5;

// Content type
header('Content-Type: image/jpeg');

// Get new sizes
list($width$height) = getimagesize($filename);
$newwidth $width $percent;
$newheight $height $percent;

// Load
$thumb imagecreatetruecolor($newwidth$newheight);
$source imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb$source0000$newwidth$newheight$width$height);

// Output
imagejpeg($thumb);
?>

The above example will output something similar to:

Output of example : Resizing an image

The image will be output at half size, though better quality could be obtained using imagecopyresampled().

Notes

Note:

There is a problem due to palette image limitations (255+1 colors). Resampling or filtering an image commonly needs more colors than 255, a kind of approximation is used to calculate the new resampled pixel and its color. With a palette image we try to allocate a new color, if that failed, we choose the closest (in theory) computed color. This is not always the closest visual color. That may produce a weird result, like blank (or visually blank) images. To skip this problem, please use a truecolor image as a destination image, such as one created by imagecreatetruecolor().

See Also

imagecopyresampled() - Copy and resize part of an image with resampling imagescale() - Scale an image using the given new width and height



imagecreate

(PHP 4, PHP 5, PHP 7)

imagecreateCreate a new palette based image

Description

imagecreate ( int $width , int $height ) : resource

imagecreate() returns an image identifier representing a blank image of specified size.

In general, we recommend the use of imagecreatetruecolor() instead of imagecreate() so that image processing occurs on the highest quality image possible. If you want to output a palette image, then imagetruecolortopalette() should be called immediately before saving the image with imagepng() or imagegif().

Parameters

width

The image width.

height

The image height.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Creating a new GD image stream and outputting an image.

<?php
header
("Content-Type: image/png");
$im = @imagecreate(11020)
    or die(
"Cannot Initialize new GD image stream");
$background_color imagecolorallocate($im000);
$text_color imagecolorallocate($im2331491);
imagestring($im155,  "A Simple Text String"$text_color);
imagepng($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : Creating a new GD image stream and outputting an image.

See Also



imagecreatefrombmp

(PHP 7 >= 7.2.0)

imagecreatefrombmpCreate a new image from file or URL

Description

imagecreatefrombmp ( string $filename ) : resource

imagecreatefrombmp() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the BMP image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Convert an BMP image to a PNG image using imagecreatefrombmp()

<?php
// Load the BMP file
$im imagecreatefrombmp('./example.bmp');

// Convert it to a PNG file with default settings
imagepng($im'./example.png');
imagedestroy($im);
?>



imagecreatefromgd2

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagecreatefromgd2Create a new image from GD2 file or URL

Description

imagecreatefromgd2 ( string $filename ) : resource

Create a new image from GD2 file or URL.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the GD2 image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 imagecreatefromgd2() example

<?php
// Load the gd2 image
$im imagecreatefromgd2('./test.gd2');

// Apply an effect on the image, in this 
// case negate the image if PHP 5+
if(function_exists('imagefilter'))
{
    
imagefilter($imIMG_FILTER_NEGATE);
}

// Save the image
imagegd2($im'./test_updated.gd2');
imagedestroy($im);
?>

Notes

Warning

The GD and GD2 image formats are proprietary image formats of libgd. They have to be regarded obsolete, and should only be used for development and testing purposes.



imagecreatefromgd2part

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagecreatefromgd2partCreate a new image from a given part of GD2 file or URL

Description

imagecreatefromgd2part ( string $filename , int $srcX , int $srcY , int $width , int $height ) : resource

Create a new image from a given part of GD2 file or URL.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the GD2 image.

srcX

x-coordinate of source point.

srcY

y-coordinate of source point.

width

Source width.

height

Source height.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 imagecreatefromgd2part() example

<?php
// For this example we need the image size before
$image getimagesize('./test.gd2');

// Create the image instance now we got the image 
// sizes
$im imagecreatefromgd2part('./test.gd2'44, ($image[0] / 2) - 6, ($image[1] / 2) - 6);

// Do an image operation, in this case we emboss the 
// image if PHP 5+
if(function_exists('imagefilter'))
{
    
imagefilter($imIMG_FILTER_EMBOSS);
}

// Save optimized image
imagegd2($im'./test_emboss.gd2');
imagedestroy($im);
?>

Notes

Warning

The GD and GD2 image formats are proprietary image formats of libgd. They have to be regarded obsolete, and should only be used for development and testing purposes.



imagecreatefromgd

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagecreatefromgdCreate a new image from GD file or URL

Description

imagecreatefromgd ( string $filename ) : resource

Create a new image from GD file or URL.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the GD file.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 imagecreatefromgd() example

<?php
// Load the gd image
$im = @imagecreatefromgd('./test.gd');

// Test if the image was loaded
if(!is_resource($im))
{
     die(
'Unable to load gd image!');
}

// Do image operations here

// Save the image
imagegd($im'./test_updated.gd');
imagedestroy($im);
?>

Notes

Warning

The GD and GD2 image formats are proprietary image formats of libgd. They have to be regarded obsolete, and should only be used for development and testing purposes.



imagecreatefromgif

(PHP 4, PHP 5, PHP 7)

imagecreatefromgifCreate a new image from file or URL

Description

imagecreatefromgif ( string $filename ) : resource

imagecreatefromgif() returns an image identifier representing the image obtained from the given filename.

Caution

When reading GIF files into memory, only the first frame is returned in the image resource pointer. The size of the image is not necessarily what is reported by getimagesize().

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the GIF image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Example to handle an error during loading of a GIF

<?php
function LoadGif($imgname)
{
    
/* Attempt to open */
    
$im = @imagecreatefromgif($imgname);

    
/* See if it failed */
    
if(!$im)
    {
        
/* Create a blank image */
        
$im imagecreatetruecolor (15030);
        
$bgc imagecolorallocate ($im255255255);
        
$tc imagecolorallocate ($im000);

        
imagefilledrectangle ($im0015030$bgc);

        
/* Output an error message */
        
imagestring ($im155'Error loading ' $imgname$tc);
    }

    return 
$im;
}

header('Content-Type: image/gif');

$img LoadGif('bogus.image');

imagegif($img);
imagedestroy($img);
?>

The above example will output something similar to:

Output of example : Example to handle an error during loading of a GIF

Notes

Note:

GIF support was removed from the GD library in Version 1.6, and added back in Version 2.0.28. This function is not available between these versions.



imagecreatefromjpeg

(PHP 4, PHP 5, PHP 7)

imagecreatefromjpegCreate a new image from file or URL

Description

imagecreatefromjpeg ( string $filename ) : resource

imagecreatefromjpeg() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the JPEG image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Example to handle an error during loading of a JPEG

<?php
function LoadJpeg($imgname)
{
    
/* Attempt to open */
    
$im = @imagecreatefromjpeg($imgname);

    
/* See if it failed */
    
if(!$im)
    {
        
/* Create a black image */
        
$im  imagecreatetruecolor(15030);
        
$bgc imagecolorallocate($im255255255);
        
$tc  imagecolorallocate($im000);

        
imagefilledrectangle($im0015030$bgc);

        
/* Output an error message */
        
imagestring($im155'Error loading ' $imgname$tc);
    }

    return 
$im;
}

header('Content-Type: image/jpeg');

$img LoadJpeg('bogus.image');

imagejpeg($img);
imagedestroy($img);
?>

The above example will output something similar to:

Output of example : Example to handle an error during loading of a JPEG


imagecreatefrompng

(PHP 4, PHP 5, PHP 7)

imagecreatefrompngCreate a new image from file or URL

Description

imagecreatefrompng ( string $filename ) : resource

imagecreatefrompng() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the PNG image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Example to handle an error during loading of a PNG

<?php
function LoadPNG($imgname)
{
    
/* Attempt to open */
    
$im = @imagecreatefrompng($imgname);

    
/* See if it failed */
    
if(!$im)
    {
        
/* Create a blank image */
        
$im  imagecreatetruecolor(15030);
        
$bgc imagecolorallocate($im255255255);
        
$tc  imagecolorallocate($im000);

        
imagefilledrectangle($im0015030$bgc);

        
/* Output an error message */
        
imagestring($im155'Error loading ' $imgname$tc);
    }

    return 
$im;
}

header('Content-Type: image/png');

$img LoadPNG('bogus.image');

imagepng($img);
imagedestroy($img);
?>

The above example will output something similar to:

imagecreatefrompng() example


imagecreatefromstring

(PHP 4 >= 4.0.4, PHP 5, PHP 7)

imagecreatefromstringCreate a new image from the image stream in the string

Description

imagecreatefromstring ( string $image ) : resource

imagecreatefromstring() returns an image identifier representing the image obtained from the given image. These types will be automatically detected if your build of PHP supports them: JPEG, PNG, GIF, BMP, WBMP, and GD2.

Parameters

image

A string containing the image data.

Return Values

An image resource will be returned on success. FALSE is returned if the image type is unsupported, the data is not in a recognised format, or the image is corrupt and cannot be loaded.

Errors/Exceptions

imagecreatefromstring() raises an E_WARNING level error, if the data is not in a recognized format.

Examples

Example #1 imagecreatefromstring() example

<?php
$data 
'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
       
'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
       
'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
       
'8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data base64_decode($data);

$im imagecreatefromstring($data);
if (
$im !== false) {
    
header('Content-Type: image/png');
    
imagepng($im);
    
imagedestroy($im);
}
else {
    echo 
'An error occurred.';
}
?>

The above example will output something similar to:

Output of example : imagecreatefromstring()

See Also



imagecreatefromwbmp

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagecreatefromwbmpCreate a new image from file or URL

Description

imagecreatefromwbmp ( string $filename ) : resource

imagecreatefromwbmp() returns an image identifier representing the image obtained from the given filename.

Note: WBMP images are Wireless Bitmaps, not Windows Bitmaps. The latter can be loaded with imagecreatefrombmp().

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the WBMP image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Example to handle an error during loading of a WBMP

<?php
function LoadWBMP($imgname)
{
    
/* Attempt to open */
    
$im = @imagecreatefromwbmp($imgname);

    
/* See if it failed */
    
if(!$im)
    {
        
/* Create a blank image */
        
$im  imagecreatetruecolor(15030);
        
$bgc imagecolorallocate($im255255255);
        
$tc  imagecolorallocate($im000);

        
imagefilledrectangle($im0015030$bgc);

        
/* Output an error message */
        
imagestring($im155'Error loading ' $imgname$tc);
    }

    return 
$im;
}

header('Content-Type: image/vnd.wap.wbmp');

$img LoadWBMP('bogus.image');

imagewbmp($img);
imagedestroy($img);
?>


imagecreatefromwebp

(PHP 5 >= 5.4.0, PHP 7)

imagecreatefromwebpCreate a new image from file or URL

Description

imagecreatefromwebp ( string $filename ) : resource

imagecreatefromwebp() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the WebP image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Convert an WebP image to a jpeg image using imagecreatefromwebp()

<?php
// Load the WebP file
$im imagecreatefromwebp('./example.webp');

// Convert it to a jpeg file with 100% quality
imagejpeg($im'./example.jpeg'100);
imagedestroy($im);
?>



imagecreatefromxbm

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagecreatefromxbmCreate a new image from file or URL

Description

imagecreatefromxbm ( string $filename ) : resource

imagecreatefromxbm() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the XBM image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Convert an XBM image to a png image using imagecreatefromxbm()

<?php
// Load the xbm file
$xbm imagecreatefromxbm('./example.xbm');

// Convert it to a png file
imagepng($xbm'./example.png');
imagedestroy($xbm);
?>



imagecreatefromxpm

(PHP 4 >= 4.0.1, PHP 5, PHP 7)

imagecreatefromxpmCreate a new image from file or URL

Description

imagecreatefromxpm ( string $filename ) : resource

imagecreatefromxpm() returns an image identifier representing the image obtained from the given filename.

Tip

A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

Parameters

filename

Path to the XPM image.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Changelog

Version Description
5.3.19 imagecreatefromxpm() is available on Windows.

Examples

Example #1 Creating an image instance using imagecreatefromxpm()

<?php
// Check for XPM support
if(!(imagetypes() & IMG_XPM))
{
    die(
'Support for xpm was not found!');
}

// Create the image instance
$xpm imagecreatefromxpm('./example.xpm');

// Do image operations here

// PHP has no support for writing xpm images
// so in this case we save the image as a 
// jpeg file with 100% quality
imagejpeg($xpm'./example.jpg'100);
imagedestroy($xpm);
?>



imagecreatetruecolor

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagecreatetruecolorCreate a new true color image

Description

imagecreatetruecolor ( int $width , int $height ) : resource

imagecreatetruecolor() returns an image identifier representing a black image of the specified size.

Parameters

width

Image width.

height

Image height.

Return Values

Returns an image resource identifier on success, FALSE on errors.

Examples

Example #1 Creating a new GD image stream and outputting an image.

<?php
header 
('Content-Type: image/png');
$im = @imagecreatetruecolor(12020)
      or die(
'Cannot Initialize new GD image stream');
$text_color imagecolorallocate($im2331491);
imagestring($im155,  'A Simple Text String'$text_color);
imagepng($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : Creating a new GD image stream and outputting an image.

See Also



imagecrop

(PHP 5 >= 5.5.0, PHP 7)

imagecropCrop an image to the given rectangle

Description

imagecrop ( resource $image , array $rect ) : resource

Crops an image to the given rectangular area and returns the resulting image. The given image is not modified.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

rect

The cropping rectangle as array with keys x, y, width and height.

Return Values

Return cropped image resource on success or FALSE on failure.

Examples

Example #1 imagecrop() example

This example shows how to crop an image to a square area.

<?php
$im 
imagecreatefrompng('example.png');
$size min(imagesx($im), imagesy($im));
$im2 imagecrop($im, ['x' => 0'y' => 0'width' => $size'height' => $size]);
if (
$im2 !== FALSE) {
    
imagepng($im2'example-cropped.png');
    
imagedestroy($im2);
}
imagedestroy($im);
?>

See Also

  • imagecropauto() - Crop an image automatically using one of the available modes


imagecropauto

(PHP 5 >= 5.5.0, PHP 7)

imagecropautoCrop an image automatically using one of the available modes

Description

imagecropauto ( resource $image [, int $mode = IMG_CROP_DEFAULT [, float $threshold = .5 [, int $color = -1 ]]] ) : resource

Automatically crops an image according to the given mode.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

mode

One of the following constants:

IMG_CROP_DEFAULT
Same as IMG_CROP_TRANSPARENT. Before PHP 7.4.0, the bundled libgd fell back to IMG_CROP_SIDES, if the image had no transparent color.
IMG_CROP_TRANSPARENT
Crops out a transparent background.
IMG_CROP_BLACK
Crops out a black background.
IMG_CROP_WHITE
Crops out a white background.
IMG_CROP_SIDES
Uses the 4 corners of the image to attempt to detect the background to crop.
IMG_CROP_THRESHOLD
Crops an image using the given threshold and color.
threshold

Specifies the tolerance in percent to be used while comparing the image color and the color to crop. The method used to calculate the color difference is based on the color distance in the RGB(a) cube.

Used only in IMG_CROP_THRESHOLD mode.

Note: Before PHP 7.4.0, the bundled libgd used a somewhat different algorithm, so the same threshold yielded different results for system and bundled libgd.

color

Either an RGB color value or a palette index.

Used only in IMG_CROP_THRESHOLD mode.

Return Values

Returns a cropped image resource on success or FALSE on failure. If the complete image was cropped, imagecrop() returns FALSE.

Changelog

Version Description
7.4.0 The behavior of imagecropauto() in the bundled libgd has been synced with that of system libgd: IMG_CROP_DEFAULT no longer falls back to IMG_CROP_SIDES and threshold-cropping now uses the same algorithm as system libgd.
7.4.0 The default value of mode has been changed to IMG_CROP_AUTO. Formerly, the default value has been -1 which corresponds to IMG_CROP_DEFAULT, but passing -1 is now deprecated.

Examples

Example #1 Proper handling of auto-cropping

As noted in the return value section, imagecropauto() returns FALSE if the whole image was cropped. In this example we have an image resource $im which should be automatically cropped only if there is something to crop; otherwise we want to proceed with the original image.

<?php
$cropped 
imagecropauto($imIMG_CROP_DEFAULT);
if (
$cropped !== false) { // in case a new image resource was returned
    
imagedestroy($im);    // we destroy the original image
    
$im $cropped;       // and assign the cropped image to $im
}
?>

See Also



imagedashedline

(PHP 4, PHP 5, PHP 7)

imagedashedlineDraw a dashed line

Description

imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) : bool

This function is deprecated. Use combination of imagesetstyle() and imageline() instead.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x1

Upper left x coordinate.

y1

Upper left y coordinate 0, 0 is the top left corner of the image.

x2

Bottom right x coordinate.

y2

Bottom right y coordinate.

color

The fill color. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagedashedline() example

<?php
// Create a 100x100 image
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Draw a vertical dashed line
imagedashedline($im50255075$white);

// Save the image
imagepng($im'./dashedline.png');
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : imagedashedline()

Example #2 Alternative to imagedashedline()

<?php
// Create a 100x100 image
$im imagecreatetruecolor(100100);
$white imagecolorallocate($im0xFF0xFF0xFF);

// Define our style: First 4 pixels is white and the 
// next 4 is transparent. This creates the dashed line effect
$style = Array(
                
$white
                
$white
                
$white
                
$white
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
IMG_COLOR_TRANSPARENT
                
);

imagesetstyle($im$style);

// Draw the dashed line
imageline($im50255075IMG_COLOR_STYLED);

// Save the image
imagepng($im'./imageline.png');
imagedestroy($im);
?>

See Also



imagedestroy

(PHP 4, PHP 5, PHP 7)

imagedestroyDestroy an image

Description

imagedestroy ( resource $image ) : bool

imagedestroy() frees any memory associated with image image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Using imagedestroy() example

<?php
// create a 100 x 100 image
$im imagecreatetruecolor(100100);

// alter or save the image

// frees image from memory
imagedestroy($im);
?>



imageellipse

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imageellipseDraw an ellipse

Description

imageellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color ) : bool

Draws an ellipse centered at the specified coordinates.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

cx

x-coordinate of the center.

cy

y-coordinate of the center.

width

The ellipse width.

height

The ellipse height.

color

The color of the ellipse. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imageellipse() example

<?php

// Create a blank image.
$image imagecreatetruecolor(400300);

// Select the background color.
$bg imagecolorallocate($image000);

// Fill the background with the color selected above.
imagefill($image00$bg);

// Choose a color for the ellipse.
$col_ellipse imagecolorallocate($image255255255);

// Draw the ellipse.
imageellipse($image200150300200$col_ellipse);

// Output the image.
header("Content-type: image/png");
imagepng($image);

?>

The above example will output something similar to:

Output of example : imageellipse()

Notes

Note:

imageellipse() ignores imagesetthickness().

See Also



imagefill

(PHP 4, PHP 5, PHP 7)

imagefillFlood fill

Description

imagefill ( resource $image , int $x , int $y , int $color ) : bool

Performs a flood fill starting at the given coordinate (top left is 0, 0) with the given color in the image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x

x-coordinate of start point.

y

y-coordinate of start point.

color

The fill color. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagefill() example

<?php

$im 
imagecreatetruecolor(100100);

// sets background to red
$red imagecolorallocate($im25500);
imagefill($im00$red);

header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : imagefill()

See Also



imagefilledarc

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagefilledarcDraw a partial arc and fill it

Description

imagefilledarc ( resource $image , int $cx , int $cy , int $width , int $height , int $start , int $end , int $color , int $style ) : bool

Draws a partial arc centered at the specified coordinate in the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

cx

x-coordinate of the center.

cy

y-coordinate of the center.

width

The arc width.

height

The arc height.

start

The arc start angle, in degrees.

end

The arc end angle, in degrees. 0° is located at the three-o'clock position, and the arc is drawn clockwise.

color

A color identifier created with imagecolorallocate().

style

A bitwise OR of the following possibilities:

  1. IMG_ARC_PIE
  2. IMG_ARC_CHORD
  3. IMG_ARC_NOFILL
  4. IMG_ARC_EDGED
IMG_ARC_PIE and IMG_ARC_CHORD are mutually exclusive; IMG_ARC_CHORD just connects the starting and ending angles with a straight line, while IMG_ARC_PIE produces a rounded edge. IMG_ARC_NOFILL indicates that the arc or chord should be outlined, not filled. IMG_ARC_EDGED, used together with IMG_ARC_NOFILL, indicates that the beginning and ending angles should be connected to the center - this is a good way to outline (rather than fill) a 'pie slice'.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Creating a 3D looking pie

<?php

// create image
$image imagecreatetruecolor(100100);

// allocate some colors
$white    imagecolorallocate($image0xFF0xFF0xFF);
$gray     imagecolorallocate($image0xC00xC00xC0);
$darkgray imagecolorallocate($image0x900x900x90);
$navy     imagecolorallocate($image0x000x000x80);
$darknavy imagecolorallocate($image0x000x000x50);
$red      imagecolorallocate($image0xFF0x000x00);
$darkred  imagecolorallocate($image0x900x000x00);

// make the 3D effect
for ($i 60$i 50$i--) {
   
imagefilledarc($image50$i10050045$darknavyIMG_ARC_PIE);
   
imagefilledarc($image50$i100504575 $darkgrayIMG_ARC_PIE);
   
imagefilledarc($image50$i1005075360 $darkredIMG_ARC_PIE);
}

imagefilledarc($image505010050045$navyIMG_ARC_PIE);
imagefilledarc($image5050100504575 $grayIMG_ARC_PIE);
imagefilledarc($image50501005075360 $redIMG_ARC_PIE);


// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

The above example will output something similar to:

Output of example : Creating a 3D looking pie



imagefilledellipse

(PHP 4 >= 4.0.6, PHP 5, PHP 7)

imagefilledellipseDraw a filled ellipse

Description

imagefilledellipse ( resource $image , int $cx , int $cy , int $width , int $height , int $color ) : bool

Draws an ellipse centered at the specified coordinate on the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

cx

x-coordinate of the center.

cy

y-coordinate of the center.

width

The ellipse width.

height

The ellipse height.

color

The fill color. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagefilledellipse() example

<?php

// create a blank image
$image imagecreatetruecolor(400300);

// fill the background color
$bg imagecolorallocate($image000);

// choose a color for the ellipse
$col_ellipse imagecolorallocate($image255255255);

// draw the white ellipse
imagefilledellipse($image200150300200$col_ellipse);

// output the picture
header("Content-type: image/png");
imagepng($image);

?>

The above example will output something similar to:

Output of example : imagefilledellipse()

Notes

Note:

imagefilledellipse() ignores imagesetthickness().

See Also



imagefilledpolygon

(PHP 4, PHP 5, PHP 7)

imagefilledpolygonDraw a filled polygon

Description

imagefilledpolygon ( resource $image , array $points , int $num_points , int $color ) : bool

imagefilledpolygon() creates a filled polygon in the given image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

points

An array containing the x and y coordinates of the polygons vertices consecutively.

num_points

Total number of points (vertices), which must be at least 3.

color

A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagefilledpolygon() example

<?php
// set up array of points for polygon
$values = array(
            
40,  50,  // Point 1 (x, y)
            
20,  240// Point 2 (x, y)
            
60,  60,  // Point 3 (x, y)
            
24020,  // Point 4 (x, y)
            
50,  40,  // Point 5 (x, y)
            
10,  10   // Point 6 (x, y)
            
);

// create image
$image imagecreatetruecolor(250250);

// allocate colors
$bg   imagecolorallocate($image000);
$blue imagecolorallocate($image00255);

// fill the background
imagefilledrectangle($image00249249$bg);

// draw a polygon
imagefilledpolygon($image$values6$blue);

// flush image
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>

The above example will output something similar to:

Output of example : imagefilledpolygon()

See Also



imagefilledrectangle

(PHP 4, PHP 5, PHP 7)

imagefilledrectangleDraw a filled rectangle

Description

imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) : bool

Creates a rectangle filled with color in the given image starting at point 1 and ending at point 2. 0, 0 is the top left corner of the image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x1

x-coordinate for point 1.

y1

y-coordinate for point 1.

x2

x-coordinate for point 2.

y2

y-coordinate for point 2.

color

The fill color. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 imagefilledrectangle() usage

<?php
// Create a 55x30 image
$im imagecreatetruecolor(5530);
$white imagecolorallocate($im255255255);

// Draw a white rectangle
imagefilledrectangle($im445025$white);

// Save the image
imagepng($im'./imagefilledrectangle.png');
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : imagefilledrectangle()



imagefilltoborder

(PHP 4, PHP 5, PHP 7)

imagefilltoborderFlood fill to specific color

Description

imagefilltoborder ( resource $image , int $x , int $y , int $border , int $color ) : bool

imagefilltoborder() performs a flood fill whose border color is defined by border. The starting point for the fill is x, y (top left is 0, 0) and the region is filled with color color.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

x

x-coordinate of start.

y

y-coordinate of start.

border

The border color. A color identifier created with imagecolorallocate().

color

The fill color. A color identifier created with imagecolorallocate().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Filling an ellipse with a color

<?php
// Create the image handle, set the background to white
$im imagecreatetruecolor(100100);
imagefilledrectangle($im00100100imagecolorallocate($im255255255));

// Draw an ellipse to fill with a black border
imageellipse($im50505050imagecolorallocate($im000));

// Set the border and fill colors
$border imagecolorallocate($im000);
$fill imagecolorallocate($im25500);

// Fill the selection
imagefilltoborder($im5050$border$fill);

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example : Filling an ellipse with a color



imagefilter

(PHP 5, PHP 7)

imagefilterApplies a filter to an image

Description

imagefilter ( resource $image , int $filtertype [, int $arg1 [, int $arg2 [, int $arg3 [, int $arg4 ]]]] ) : bool

imagefilter() applies the given filter filtertype on the image.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

filtertype

filtertype can be one of the following:

  • IMG_FILTER_NEGATE: Reverses all colors of the image.
  • IMG_FILTER_GRAYSCALE: Converts the image into grayscale by changing the red, green and blue components to their weighted sum using the same coefficients as the REC.601 luma (Y') calculation. The alpha components are retained. For palette images the result may differ due to palette limitations.
  • IMG_FILTER_BRIGHTNESS: Changes the brightness of the image. Use arg1 to set the level of brightness. The range for the brightness is -255 to 255.
  • IMG_FILTER_CONTRAST: Changes the contrast of the image. Use arg1 to set the level of contrast.
  • IMG_FILTER_COLORIZE: Like IMG_FILTER_GRAYSCALE, except you can specify the color. Use arg1, arg2 and arg3 in the form of red, green, blue and arg4 for the alpha channel. The range for each color is 0 to 255.
  • IMG_FILTER_EDGEDETECT: Uses edge detection to highlight the edges in the image.
  • IMG_FILTER_EMBOSS: Embosses the image.
  • IMG_FILTER_GAUSSIAN_BLUR: Blurs the image using the Gaussian method.
  • IMG_FILTER_SELECTIVE_BLUR: Blurs the image.
  • IMG_FILTER_MEAN_REMOVAL: Uses mean removal to achieve a "sketchy" effect.
  • IMG_FILTER_SMOOTH: Makes the image smoother. Use arg1 to set the level of smoothness.
  • IMG_FILTER_PIXELATE: Applies pixelation effect to the image, use arg1 to set the block size and arg2 to set the pixelation effect mode.
  • IMG_FILTER_SCATTER: Applies scatter effect to the image, use arg1 and arg2 to define the effect strength and additionally arg3 to only apply the on select pixel colors.

arg1

  • IMG_FILTER_BRIGHTNESS: Brightness level.
  • IMG_FILTER_CONTRAST: Contrast level.
  • IMG_FILTER_COLORIZE: Value of red component.
  • IMG_FILTER_SMOOTH: Smoothness level.
  • IMG_FILTER_PIXELATE: Block size in pixels.
  • IMG_FILTER_SCATTER: Effect substraction level. This must not be higher or equal to the addition level set with arg2.

arg2

  • IMG_FILTER_COLORIZE: Value of green component.
  • IMG_FILTER_PIXELATE: Whether to use advanced pixelation effect or not (defaults to FALSE).
  • IMG_FILTER_SCATTER: Effect addition level.

arg3

  • IMG_FILTER_COLORIZE: Value of blue component.
  • IMG_FILTER_SCATTER: Optional array indexed color values to apply effect at.

arg4

  • IMG_FILTER_COLORIZE: Alpha channel, A value between 0 and 127. 0 indicates completely opaque while 127 indicates completely transparent.

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version Description
7.4.0 Scatter support (IMG_FILTER_SCATTER) was added.
5.3.0 Pixelation support (IMG_FILTER_PIXELATE) was added.
5.2.5 Alpha support for IMG_FILTER_COLORIZE was added.

Examples

Example #1 imagefilter() grayscale example

<?php
$im 
imagecreatefrompng('dave.png');

if(
$im && imagefilter($imIMG_FILTER_GRAYSCALE))
{
    echo 
'Image converted to grayscale.';

    
imagepng($im'dave.png');
}
else
{
    echo 
'Conversion to grayscale failed.';
}

imagedestroy($im);
?>

Example #2 imagefilter() brightness example

<?php
$im 
imagecreatefrompng('sean.png');

if(
$im && imagefilter($imIMG_FILTER_BRIGHTNESS20))
{
    echo 
'Image brightness changed.';

    
imagepng($im'sean.png');
    
imagedestroy($im);
}
else
{
    echo 
'Image brightness change failed.';
}
?>

Example #3 imagefilter() colorize example

<?php
$im 
imagecreatefrompng('philip.png');

/* R, G, B, so 0, 255, 0 is green */
if($im && imagefilter($imIMG_FILTER_COLORIZE02550))
{
    echo 
'Image successfully shaded green.';

    
imagepng($im'philip.png');
    
imagedestroy($im);
}
else
{
    echo 
'Green shading failed.';
}
?>

Example #4 imagefilter() negate example

<?php
// Define our negate function so its portable for 
// php versions without imagefilter()
function negate($im)
{
    if(
function_exists('imagefilter'))
    {
        return 
imagefilter($imIMG_FILTER_NEGATE);
    }

    for(
$x 0$x imagesx($im); ++$x)
    {
        for(
$y 0$y imagesy($im); ++$y)
        {
            
$index imagecolorat($im$x$y);
            
$rgb imagecolorsforindex($index);
            
$color imagecolorallocate($im255 $rgb['red'], 255 $rgb['green'], 255 $rgb['blue']);

            
imagesetpixel($im$x$y$color);
        }
    }

    return(
true);
}

$im imagecreatefromjpeg('kalle.jpg');

if(
$im && negate($im))
{
    echo 
'Image successfully converted to negative colors.';

    
imagejpeg($im'kalle.jpg'100);
    
imagedestroy($im);
}
else
{
    echo 
'Converting to negative colors failed.';
}
?>

Example #5 imagefilter() pixelate example

<?php
// Load the PHP logo, we need to create two instances 
// to show the differences
$logo1 imagecreatefrompng('./php.png');
$logo2 imagecreatefrompng('./php.png');

// Create the image instance we want to show the 
// differences on
$output imagecreatetruecolor(imagesx($logo1) * 2imagesy($logo1));

// Apply pixelation to each instance, with a block 
// size of 3
imagefilter($logo1IMG_FILTER_PIXELATE3);
imagefilter($logo2IMG_FILTER_PIXELATE3true);

// Merge the differences onto the output image
imagecopy($output$logo10000imagesx($logo1) - 1imagesy($logo1) - 1);
imagecopy($output$logo2imagesx($logo2), 000imagesx($logo2) - 1imagesy($logo2) - 1);
imagedestroy($logo1);
imagedestroy($logo2);

// Output the differences
header('Content-Type: image/png');
imagepng($output);
imagedestroy($output);
?>

The above example will output something similar to:

Output of example : imagefilter() pixelate

Example #6 imagefilter() scatter example

<?php
// Load the image
$logo imagecreatefrompng('./php.png');

// Apply a very soft scatter effect to the image
imagefilter($logoIMG_FILTER_SCATTER35);

// Output the image with the scatter effect
header('Content-Type: image/png');
imagepng($logo);
imagedestroy($logo);
?>

The above example will output something similar to:

Output of example : imagefilter() scatter

Notes

Note: The result of IMG_FILTER_SCATTER is always random.

See Also



imageflip

(PHP 5 >= 5.5.0, PHP 7)

imageflipFlips an image using a given mode

Description

imageflip ( resource $image , int $mode ) : bool

Flips the image image using the given mode.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

mode

Flip mode, this can be one of the IMG_FLIP_* constants:

Constant Meaning
IMG_FLIP_HORIZONTAL Flips the image horizontally.
IMG_FLIP_VERTICAL Flips the image vertically.
IMG_FLIP_BOTH Flips the image both horizontally and vertically.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example #1 Flips an image vertically

This example uses the IMG_FLIP_VERTICAL constant.

<?php
// File
$filename 'phplogo.png';

// Content type
header('Content-type: image/png');

// Load
$im imagecreatefrompng($filename);

// Flip it vertically
imageflip($imIMG_FLIP_VERTICAL);

// Output
imagejpeg($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example: Vertically flipped image

Example #2 Flips the image horizontally

This example uses the IMG_FLIP_HORIZONTAL constant.

<?php
// File
$filename 'phplogo.png';

// Content type
header('Content-type: image/png');

// Load
$im imagecreatefrompng($filename);

// Flip it horizontally
imageflip($imIMG_FLIP_HORIZONTAL);

// Output
imagejpeg($im);
imagedestroy($im);
?>

The above example will output something similar to:

Output of example: Horizontally flipped image



imagefontheight

(PHP 4, PHP 5, PHP 7)

imagefontheightGet font height

Description

imagefontheight ( int $font ) : int

Returns the pixel height of a character in the specified font.

Parameters

font

Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

Return Values

Returns the pixel height of the font.

Examples

Example #1 Using imagefontheight() on built-in fonts

<?php
echo 'Font height: ' imagefontheight(4);
?>

The above example will output something similar to:

   Font height: 16
   

Example #2 Using imagefontheight() together with imageloadfont()

<?php
// Load a .gdf font
$font imageloadfont('anonymous.gdf');

echo 
'Font height: ' imagefontheight($font);
?>

The above example will output something similar to:

   Font height: 43
   

See Also



imagefontwidth

(PHP 4, PHP 5, PHP 7)

imagefontwidthGet font width

Description

imagefontwidth ( int $font ) : int

Returns the pixel width of a character in font.

Parameters

font

Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

Return Values

Returns the pixel width of the font.

Examples

Example #1 Using imagefontwidth() on built-in fonts

<?php
echo 'Font width: ' imagefontwidth(4);
?>

The above example will output something similar to:

   Font width: 8
   

Example #2 Using imagefontwidth() together with imageloadfont()

<?php
// Load a .gdf font
$font imageloadfont('anonymous.gdf');

echo 
'Font width: ' imagefontwidth($font);
?>

The above example will output something similar to:

   Font width: 23
   

See Also



imageftbbox

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imageftbboxGive the bounding box of a text using fonts via freetype2

Description

imageftbbox ( float $size , float $angle , string $fontfile , string $text [, array $extrainfo ] ) : array

This function calculates and returns the bounding box in pixels for a FreeType text.

Note:

imageftbbox() is an extended variant of imagettfbbox() which additionally supports the extrainfo.

Parameters

size

The font size in points.

angle

Angle in degrees in which text will be measured.

fontfile

The name of the TrueType font file (can be a URL). Depending on which version of the GD library that PHP is using, it may attempt to search for files that do not begin with a leading '/' by appending '.ttf' to the filename and searching along a library-defined font path.

text

The string to be measured.

extrainfo

Possible array indexes for extrainfo
Key Type Meaning
linespacing float Defines drawing linespacing

Return Values

imageftbbox() returns an array with 8 elements representing four points making the bounding box of the text:
0 lower left corner, X position
1 lower left corner, Y position
2 lower right corner, X position
3 lower right corner, Y position
4 upper right corner, X position
5 upper right corner, Y position
6 upper left corner, X position
7 upper left corner, Y position

The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontally.

Examples

Example #1 imageftbbox() example

<?php
// Create a 300x150 image
$im imagecreatetruecolor(300150);
$black imagecolorallocate($im000);
$white imagecolorallocate($im255255255);

// Set the background to be white
imagefilledrectangle($im00299299$white);

// Path to our font file
$font './arial.ttf';

// First we create our bounding box
$bbox imageftbbox(100$font'The PHP Documentation Group');

// This is our cordinates for X and Y
$x $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;

imagefttext($im100$x$y$black$font'The PHP Documentation Group');

// Output to browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

Notes

Note: This function is only available if PHP is compiled with freetype support (--with-freetype-dir=DIR)

See Also

  • imagefttext() - Write text to the image using fonts using FreeType 2
  • imagettfbbox() - Give the bounding box of a text using TrueType fonts



imagefttext

(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagefttextWrite text to the image using fonts using FreeType 2

Description

imagefttext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text [, array $extrainfo ] ) : array

Note:

imagefttext() is an extended variant of imagettftext() which additionally supports the extrainfo.

Parameters

image

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

size

The font size to use in points.

angle

The angle in degrees, with 0 degrees being left-to-right reading text. Higher values represent a counter-clockwise rotation. For example, a value of 90 would result in bottom-to-top reading text.

x

The coordinates given by x and y will define the basepoint of the first character (roughly the lower-left corner of the character). This is different from the imagestring(), where x and y define the upper-left corner of the first character. For example, "top left" is 0, 0.

y

The y-ordinate. This sets the position of the fonts baseline, not the very bottom of the character.

color

The index of the desired color for the text, see imagecolorexact().

fontfile

The path to the TrueType font you wish to use.

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

When using versions of the GD library lower than 2.0.18, a space character, rather than a semicolon, was used as the 'path separator' for different font files. Unintentional use of this feature will result in the warning message: Warning: Could not find/open font. For these affected versions, the only solution is moving the font to a path which does not contain spaces.

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

<?php
// Set the enviroment variable for GD
putenv('GDFONTPATH=' realpath('.'));

// Name the font to be used (note the lack of the .ttf extension)
$font 'SomeFont';
?>

text

Text to be inserted into image.

extrainfo

Possible array indexes for extrainfo
Key Type Meaning
linespacing float Defines drawing linespacing

Return Values

This function returns an array defining the four points of the box, starting in the lower left and moving counter-clockwise:
0 lower left x-coordinate
1 lower left y-coordinate
2 lower right x-coordinate
3 lower right y-coordinate
4 upper right x-coordinate
5 upper right y-coordinate
6 upper left x-coordinate
7 upper left y-coordinate

Examples

Example #1 imagefttext() example

<?php
// Create a 300x100 image
$im imagecreatetruecolor(300100);
$red imagecolorallocate($im0xFF0x000x00);
$black imagecolorallocate($im0x000x000x00);

// Make the background red
imagefilledrectangle($im0029999$red);

// Path to our ttf font file
$font_file './arial.ttf';

// Draw the text 'PHP Manual' using font size 13
imagefttext($im13010555$black$font_file'PHP Manual');

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

Notes

Note: This function is only available if PHP is compiled with freetype support (--with-freetype-dir=DIR)

See Also

  • imageftbbox() - Give the bounding box of a text using fonts via freetype2
  • imagettftext() - Write text to the image using TrueType fonts